标签:
<system.web><authentication mode="None" /><compilation debug="true" targetFramework="4.6.1" /><httpRuntime targetFramework="4.6.1" /><authentication mode="Forms"><forms loginUrl="~/Login/Index" timeout="1440" /></authentication><httpModules><add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" /></httpModules></system.web>
//登陆
public ActionResult Index(LoginViewModel model)
{
if (db.User.Count(x => x.Account == strUser && x.Password == strPassword && x.Enable == true) > 0)
{
//用户验证成功
FormsAuthentication.SetAuthCookie(strUser, model.Remember);
return RedirectToAction("Index", "Admin", new { pagesize = 10 });
}
else
{
return View();
}
}
//退出登陆
public ActionResult Logout()
{
FormsAuthentication.SignOut();
return RedirectToAction("Index", "Login");
3、验证登陆及权限检查,需要让所有需要登陆的页面从BaseController派生
4、密码MD5加密
标签:
原文地址:http://www.cnblogs.com/dusthunter/p/5901647.html