我在 AccountController 中有 LogOn 部分视图:
public ActionResult LogOn()
{
return PartialView();
}
//
// POST: /Account/LogOn
[HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (ModelState.IsValid)
{
if (MembershipService.ValidateUser(model.UserName, model.Password))
{
FormsService.SignIn(model.UserName, model.RememberMe);
}
else
{
ModelState.AddModelError("", Resources.Account.Account.LoginFailureText);
}
}
}
return PartialView(model);
}
,我在我的 _Layout.cshtml 中呈现这个部分:
@{Html.RenderAction("LogOn", "Account");}
LogOn.cshtml 视图是:
@model Kalimat.Web.Models.LogOnModel
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<div class="leftbanner login">
<div class="bookicon">
<img src="@Url.Content(@Kalimat.Web.Resources.Common.bookiconImgSrc)" alt="@Kalimat.Web.Resources.Common.bookiconImgAlt" />
</div>
<div class="strip">
@MvcHtmlString.Create(Kalimat.Web.Resources.Account.Account.LoginTitle)
</div>
<div class="shade_2">
<img src="@Url.Content(@Kalimat.Web.Resources.Common.shade_2ImgSrc)" alt="@Kalimat.Web.Resources.Common.shade_2ImgAlt" />
</div>
<div class="insidetext">
@{
//Logined user view
if (Request.IsAuthenticated)
{
<div id="LoginView1">
@{<text>@Kalimat.Web.Resources.Account.Account.WelcomeText <strong>@Model.UserName</strong>!</text>}
<br />
<a id="LoginStatus1" href="">@Kalimat.Web.Resources.Account.Account.LoginStatusText</a>
<a id="ChangePassLinkButton" href="">@Kalimat.Web.Resources.Account.Account.ChangePswText</a>
</div>
}
else
{
@Html.LabelFor(m => m.UserName)
@Html.TextBoxFor(m => m.UserName, new { @class = "inputfield" })
@Html.ValidationMessageFor(m => m.UserName, "*")
<br />
@Html.LabelFor(m => m.Password)
@Html.PasswordFor(m => m.Password, new { @class = "inputfield" })
@Html.ValidationMessageFor(m => m.Password, "*")
<br />
<span class="remove_shop">
@Html.CheckBoxFor(m => m.RememberMe)
@Html.LabelFor(m => m.RememberMe)
</span>
<p>
***<input type="submit" class="submit_Cart" value="@Kalimat.Web.Resources.Account.Account.LoginButtonText" />***
</p>
@Html.ValidationSummary(false, Kalimat.Web.Resources.Account.Account.LoginFailureText)
<a class="submit_Cart" href="">@Kalimat.Web.Resources.Account.Account.NewAccountText</a>
<br />
<a class="submit_Cart" href="">@Kalimat.Web.Resources.Account.Account.RecoverPswText</a>
}
}
</div>
</div>
当我运行应用程序时,LogOn 视图呈现正确,但单击提交按钮时没有任何反应。为什么?