FormsAuthentication.SignOut(); FormsAuthentication.SetAuthCookie(u.UserName, false);
2016-09-07 15:38
393 查看
//Authentication/Login
// GET: Authentication
public ActionResult Login()
{
return View();
}
public ActionResult Logout()
{
FormsAuthentication.SignOut();
return RedirectToAction("Login");
}
[HttpPost]
public ActionResult DoLogin(UserDetails u)//Authentication/DoLogin
{
EmployeeBusinessLayer bal = new EmployeeBusinessLayer();
if (bal.IsValidUser(u))
{
FormsAuthentication.SetAuthCookie(u.UserName, false);
return RedirectToAction("Index", "HOME");
}
else
{
ModelState.AddModelError("CredentialError", "Invalid Username or Password");
return View("Login");
}
}
// GET: Authentication
public ActionResult Login()
{
return View();
}
public ActionResult Logout()
{
FormsAuthentication.SignOut();
return RedirectToAction("Login");
}
[HttpPost]
public ActionResult DoLogin(UserDetails u)//Authentication/DoLogin
{
EmployeeBusinessLayer bal = new EmployeeBusinessLayer();
if (bal.IsValidUser(u))
{
FormsAuthentication.SetAuthCookie(u.UserName, false);
return RedirectToAction("Index", "HOME");
}
else
{
ModelState.AddModelError("CredentialError", "Invalid Username or Password");
return View("Login");
}
}
相关文章推荐
- Asp.net MVC Form认证,IIS改成集成模式后,FormsAuthentication.SetAuthCookie无效,Request.IsAuthenticated值,始终为false,页面提示HTTP 错误 401.0 - Unauthorized,您无权查看此目录或页面
- ios中mvc的FormsAuthentication.SetAuthCookie(cookieUserName, false)失败
- FormsAuthentication.SetAuthCookie Method
- MVC .NET的FormsAuthentication.SetAuthCookie在IE10中无效的问题
- IE10下 FormsAuthentication.SetAuthCookie无效的问
- FormsAuthentication.SetAuthCookie
- asp.net mvc 中[Authorize]在IE9以上版本关于FormsAuthentication.SetAuthCookie无效的问题 解决方案
- FormsAuthentication.SetAuthCookie
- FormsAuthentication.SetAuthCookie
- FormsAuthentication.SetAuthCookie
- asp.net 登陆验证 Form表单验证的3种方式 FormsAuthentication.SetAuthCookie;FormsAuthentication.RedirectFromLoginPage;FormsAuthenticationTicket
- FormsAuthentication.SetAuthCookie 方法登录
- FormsAuthentication.Signout不能清楚服务器端cookie
- FormsAuthentication.SetAuthCookie 方法 (String, Boolean)
- FormsAuthentication.SetAuthCookie
- 用 FormsAuthentication.SetAuthCookie 做权限验证
- MVC4 Forms 验证,部署到Hyper-v上.FormsAuthentication.SetAuthCookie无效的问题
- asp.net 登陆验证 Form表单验证的3种方式 FormsAuthentication.SetAuthCookie;FormsAuthentication.RedirectFromLoginPage;FormsAuthenticationTicket
- FormsAuthentication.SetAuthCookie是必须写的吗?
- asp.net 登陆验证 Form表单验证的3种方式 FormsAuthentication.SetAuthCookie;FormsAuthentication.RedirectFromLoginPage;FormsAuthenticationTicket