在一个新创建的 MVC4 应用程序中,将此函数插入到帐户控制器中
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult AdminLogin(AdminLoginModel model, string returnUrl)
{
if (ModelState.IsValid && WebSecurity.Login("administrator", model.Password, persistCookie: model.RememberMe))
{
return RedirectToLocal(returnUrl);
}
// If we got this far, something failed, redisplay form
ModelState.AddModelError("", "The password provided is incorrect.");
return View(model);
}
还有这个
public class AdminLoginModel
{
[Required]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[Display(Name = "Remember me?")]
public bool RememberMe { get; set; }
}
放入accountModel.cs。我还创建了一个新文件 AdminLogin.cshtml 并将其留空。在 _loginPartial.cshtml 文件中,我插入了一个操作链接
<li>@Html.ActionLink("Register", "AdminLogin", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })</li>
但是,当我单击该注册链接时,我会看到 404 错误指出
/Account/AdminLogin
未找到。
我在插入那个微小的 mvc 的过程中错过了一些东西;你可以帮帮我吗 ?我是一个 mvc 初学者。