2
我使用登錄表單創建了一個網站。首先,我創建登錄表單,只是爲了在帳戶/登錄下進行測試。然後有些需要更改所有頁面應該顯示登錄。所以,我創建一個部分,並在_Layout.cshtml以下打電話,從部分視圖獲得價值mvc剃刀
<div id="logindisplay">
@{ Html.RenderPartial("_LogOnPartial"); }
</div>
_LogOnPartial.cshtml:
@model HOP2013.Models.LogOnModel
@{
ViewBag.Title = "Log On";
}
@if(Request.IsAuthenticated) {
<text>Welcome <b>@Context.User.Identity.Name</b>!
[ @Html.ActionLink("Log Off", "LogOff", "Account") ]</text>
}
else {
@: @Html.ActionLink("Log On", "LogOn", "Account")
}
@Html.ValidationSummary(true, "Login was unsuccessful. Please correct the errors and try again.")
@using (Html.BeginForm()) {
<fieldset>
<legend>Account Information</legend>
<div id="user" class="user">
<div class="editor-label">
@Html.LabelFor(m => m.UserName)
</div>
<div class="editor-field">
@Html.TextBoxFor(m => m.UserName, new { @title = "UserName" })
@Html.ValidationMessageFor(m => m.UserName)
</div>
</div>
<div id="password" class="password">
<div class="editor-label">
@Html.LabelFor(m => m.Password)
</div>
<div class="editor-field">
@Html.PasswordFor(m => m.Password, new { @title = "UserName" })
@Html.ValidationMessageFor(m => m.Password)
</div>
<div class="editor-label">
@Html.CheckBoxFor(m => m.RememberMe)
@Html.LabelFor(m => m.RememberMe)
</div>
</div>
<p>
<input type="submit" class="login" value="Log On" />
</p>
<p>New @Html.ActionLink("Register", "SignUp", "Account")Here</p>
</fieldset>
}
但我不能登錄。如果我使用單獨的頁面(LogOn.cshtml)登錄意味着它正在成功記錄。我不知道它爲什麼會發生。任何人都會澄清我。