单击导航栏中的链接时为什么会出错?

时间:2017-11-13 08:48:51

标签: asp.net-mvc

我使用asp.net mvc 5。 我在渲染体元素上面的布局页面中创建了弹出窗口:

    <div class="body-content" style="padding-left:15px;padding-right:15px;">
        <!-- Subscribers popup -->
        <div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <!-- Modal Body -->
                    <div class="modal-body">
                        @Html.Partial("~/Views/Account/Login.cshtml")                         
                    </div>
                </div>
            </div>
        </div>
        <!-- /Subscribers popup -->
        @RenderBody()
    </div> 

这里看看Login.cshtml:

@model GeomindEnterprise.Models.LoginViewModel

<div class="row">
    <div class="col-md-6 col-sm-6 col-xs-6">
        <!-- /SOCIAL LOGIN -->
        @using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "sky-form", role = "form" }))
        {
            @Html.AntiForgeryToken()

            @Html.ValidationSummary(true, "", new { @class = "text-danger" })

            <label class="input margin-bottom-10">
                <i class="ico-append fa fa-envelope"></i>
                @Html.TextBoxFor(m => m.UserName, new { @placeholder = "Email" })
                @Html.ValidationMessageFor(m => m.UserName, "", new { @class = "text-danger" })
            </label>

            <label class="input margin-bottom-10">
                <i class="ico-append fa fa-lock"></i>
                @Html.PasswordFor(m => m.Password, new { placeholder = "Password" })
                @Html.ValidationMessageFor(m => m.Password, "", new { @class = "text-danger" })
            </label>

            <label class="form-group">
                @Html.CheckBoxFor(m => m.RememberMe, new { @class = "col-md-1" })
                @Html.LabelFor(m => m.RememberMe)
            </label>

            <footer>
                <button type="submit" class="btn btn-default noradius pull-right"><i class="fa fa-check"></i> OK, LOG IN</button>
            </footer>
        }
    </div>

</div>

同样在布局页面中我有这个导航栏:

            <div class="navbar-collapse pull-left nav-main-collapse collapse">
                <nav class="nav-main">
                    <ul id="topMain" class="nav nav-pills nav-main">
                        <li>@Html.ActionLink(@Resources.Resources.Home, "Index", "Home")</li>
                        <li>@Html.ActionLink(@Resources.Resources.About, "About", "Home")</li>
                        <li>@Html.ActionLink(@Resources.Resources.Contact, "Contact", "Home")</li>
                        <li><a href="#" data-toggle="modal" data-target="#myModal">@Resources.Resources.Subscribers</a></li>
                        @if (Request.IsAuthenticated && User.IsInRole("Admin"))
                        {
                            <li>@Html.ActionLink("Back office", "BackOfficeMain", "BackOffice")</li>
                            <li>@Html.ActionLink("RolesAdmin", "Index", "RolesAdmin")</li>
                            <li>@Html.ActionLink("UsersAdmin", "Index", "UsersAdmin")</li>
                            <li>@Html.ActionLink("GroupsAdmin", "Index", "GroupsAdmin")</li>
                        }
                    </ul>
                </nav>
            </div>

当我点击Back office或RolesAdmin或UsersAdmin或GroupsAdmin时,我收到此错误:

  

传递到字典中的模型项的类型为&#39; System.Collections.Generic.List`1 [GeomindEnterprise.Models.ApplicationUser]&#39;,但此字典需要类型为&#39的模型项; GeomindEnterprise.Models.LoginViewModel&#39;

在这一行:

@Html.Partial("~/Views/Account/Login.cshtml")

知道为什么我上面会出现错误,如何防止上述错误?

0 个答案:

没有答案
相关问题