1
I am developing an ASP.NET application and when the user logs in and clicks on the browser button to go back he can access the login/registration page, even if I check the logged-in user’s key on Session.
Follow the prints:
1 - Fiz login
2 - I am logged in, the site redirects me to the index and I click the back button.
3 - After that I go back to the registration/login screen which can not happen:
After photo 3, if I go back to index, I log in normally, to prevent this I did a check in the controller checking whether the user is logged in or not, if yes it goes back to index, but when the user clicks back it looks like the browser that does this control. I’ve seen sites that don’t allow you to go back to the login screen, does anyone know how to fix it? Follow the check in the controller:
public ActionResult LoginRegister()
{
if (Session["UserStatus"] != null)
{
return RedirectToAction("Index", "Home");
}
return View();
}
[HttpPost]
public ActionResult LoginRegister(string fr,string t,string ReT)
{
if (Session["UserStatus"] != null)
{
return RedirectToAction("Index", "Home");
}
//Validação e outros processos.
}
Cassio will apply your solution soon return with the result, VLW
– Leonardo Bonetti