【发布时间】:2013-12-06 09:03:39
【问题描述】:
Cannot perform runtime binding on a null reference error
我在局部视图中收到此错误。
loginUserExists = Membership.ValidateUser(UserNameLogin, PasswordUserLogin);
if (loginUserExists==false)
{
return;
}
FormsAuthentication.SetAuthCookie(UserNameLogin, true);
这是我产生错误的部分观点。
@*This is where the error happens*@
**@if (!Page.User.Identity.IsAuthenticated)**
{
<li><a href="@Url.Action("LoginForm", "Home")">Login</a></li>
<li><a href="@Url.Action("RegisterForm", "Home")">Register</a></li>
}
else
{
<li><a href="@Url.Action("LoginForm", "Home")">Logout</a></li>
if (Model.FirstName != null)
{
<li><label id="labUserName">@Model.FirstName</label></li>
}
}
局部视图嵌套在布局页面中。
也许了解我为什么会得到这个以及如何克服它?
问候
【问题讨论】:
标签: asp.net-mvc-3 asp.net-membership