0

I am building an Asp.net MVC application and hazardous is the fact below: I open the Login.cshtml page and I give an incorrect username and/or password and I click on Login. Naturally, It shows me the error messages from the LoginController.cs "Username and/or Password are incorrect!" . After this unsuccessful tentative, I try again entering a correct username and password and the Login page redirects me to /Template/Index . When I click on the <- button on the browser to go back to the Login.cshtml view, it shows me the old error message "Username and/or Password are incorrect!" . By means of the debugger I have managed to see that the UserViewModel in the Login method has the old username & password when I redirect to the Login page. Anybody any helpful ideas how to overcome this ? Thank you very much in advance for your help!

  • You can set the expiry of the document or controller it can help. If you are calling any api then set expiry time there too. So that the old response does not get cached on browser. [Refer this question](https://stackoverflow.com/questions/10011780/prevent-caching-in-asp-net-mvc-for-specific-actions-using-an-attribute) – शेखर Dec 04 '19 at 08:59
  • I understand, but if I disable the cache either by creating a custom [NoCache] attribute or by using ajax cache:false, I can't even be redirected to Login.cshtml after having opened the dashboard. You understand what I mean by this. –  Dec 04 '19 at 09:09
  • No I don't understand your point. You can redirect to login.cshtml any time hardly matters with cache enabled or disabled. – शेखर Dec 04 '19 at 09:17
  • I understand what you mean but it gives me an error saying that "some other data needed to redirect to Login" –  Dec 04 '19 at 09:31
  • Furthermore, the user has the option "Remember Me" :( –  Dec 04 '19 at 09:32
  • Can you share Code and Some images of it ?? – Neel Darji Dec 04 '19 at 10:44

0 Answers0