单击提交按钮时,我被卡住了。单击提交按钮后,它不会返回到 HttpPost 操作。我正在共享我的代码。
控制器: 公共类 AccountController:控制器 {
public ActionResult Index()
{
return View();
}
//
// GET: /Account/LogOn
public ActionResult UserLogin()
{
return View();
}
[HttpPost]
public ActionResult UserLogin(LogOn model)
{
if (ModelState.IsValid)
{
return View("Compltete", model);
}
// If we got this far, something failed, redisplay form
return View(model);
}
}
看法:
@model SanjiviniAnalytics.Models.LogOn
<h2>User Login</h2>
<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>
@using (Html.BeginForm("UserLogin", "Account", FormMethod.Post)) {
<div>
<fieldset>
<legend>Sign In</legend>
<div class="editor-label">
@Html.LabelFor(m => m.UserName)
</div>
<div class="editor-field">
@Html.TextBoxFor(m => m.UserName)
@Html.ValidationMessageFor(m => m.UserName)
</div>
<div class="editor-label">
@Html.LabelFor(m => m.Password)
</div>
<div class="editor-field">
@Html.PasswordFor(m => m.Password)
@Html.ValidationMessageFor(m => m.Password)
</div>
<p>
<input type="submit" value="Log In" />
</p>
</fieldset>
</div>
}
模型:
public class LogOn
{
[Required]
[Display(Name="User Name")]
public string UserName { get; set; }
[Required]
[Display(Name="Password")]
[DataType(DataType.Password)]
public string Password { get; set;}
}
谁能帮我找出我哪里出错了?