1)请更改您的默认路线:
routes.MapRoute(
"DefaultSite",
"{controller}/{action}/{id}",
new
{
controller ="Account",
action ="LogOn",
id = UrlParameter.Optional
}
);
2)加载部分主加载文件:
@using (Html.BeginForm("LogOn","Account",HttpMethod.Post))
{
@Html.AntiForgeryToken()
@Html.Partial( "~/Views/Home/LogOn.cshtml", new MyProject.Models.LogOnModel())
}
3)并且帐户控制器添加了您的登录逻辑:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Login(LogOnModel model)
{
if (ModelState.IsValid)
{
//TODO:
return RedirectToAction("index", "home");
}
// If we got this far, something failed, redisplay form
ModelState.AddModelError("", @"The user name or password provided is incorrect.");
return View(model);
}