Tag: authorize

MVC 4表单身份validation无法与一起使用

我现在正在学习MVC4,我正在按照Pro ASP NET MVC4第4版的书来创建一个体育商店项目。 我一直在webforms中开发,我试图弄清楚表单身份validation在MVC4中是如何工作的。 这是我取得的成就: Web.Config中 AccountController登录动作: [HttpPost] public ActionResult Login(LoginViewModel model, string returnUrl) { if (ModelState.IsValid) { if (authProvider.Authenticate(model.UserName, model.Password)) { return Redirect(returnUrl ?? Url.Action(“Index”, “Admin”)); } else { ModelState.AddModelError(“”, “Incorrect username or password”); return View(); } } else { return View(); } } 认证提供者: public bool Authenticate(string username, string password) { bool […]