I am wondering how the Session ID works in Forms Authentication? Becuase I did a Response.Write(Session.SessionID); on my home controller and then logged out. I then logged in as a new User and the Session ID was the same. Below are my LogOn and LogOff Actions:
LogOn:
[HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
try
{
if (ModelState.IsValid)
{
if (Membership.ValidateUser(model.UserName, model.Password))
{
FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
&& !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
{
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("LogonError", model);
}
catch (Exception ex)
{
string test = ex.Message;
return PartialView("_Error", test);
}
}
LogOff:
public ActionResult LogOff()
{
FormsAuthentication.SignOut();
return RedirectToAction("Index", "Home");
}