Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [AllowAnonymous]
- [HttpPost]
- public ActionResult Login(LoginModel model, string returnUrl)
- {
- if (ModelState.IsValid)
- {
- if (System.Web.Security.Membership.ValidateUser(model.UserName, model.Password))
- {
- FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
- if (Url.IsLocalUrl(returnUrl))
- {
- return Redirect(returnUrl);
- }
- else
- {
- return RedirectToAction("Index", "Home");
- }
- }
- else
- {
- ModelState.AddModelError("", "The user name or password provided is incorrect.");
- }
- }
- // If we got this far, something failed, redisplay form
- return View(model);
- }
- <authentication mode="Forms">
- <forms loginUrl="~/Account/Login" timeout="3600" />
- </authentication>
- <!--<modules>
- <remove name="FormsAuthentication" />
- </modules>-->
- [AllowAnonymous]
- [HttpPost]
- public ActionResult Login(string userName, string password, string returnUrl)
- {
- if (ModelState.IsValid)
- {
- if (HttpContext.User.Identity.IsAuthenticated)
- {
- return View(returnUrl);
- }
- else
- {
- if (System.Web.Security.Membership.ValidateUser(userName, password))
- {
- FormsAuthentication.SetAuthCookie(userName, false);
- if (Url.IsLocalUrl(returnUrl))
- {
- return RedirectToAction("Login", new { userName = userName, password = password, returnUrl = returnUrl });
- //return Redirect(returnUrl);
- }
- else
- {
- return RedirectToAction("Index", "Home");
- }
- }
- }
- else
- {
- ModelState.AddModelError("", "The user name or password provided is incorrect.");
- }
- }
- // If we got this far, something failed, redisplay form
- return View(model);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement