0

User first go through registration and then after successful registration, user redirects to welcome page. At welcome page user successfully logged-in the website. But if someone click the back browser button then the previous registration page doesn't show any log-in user. And when we refresh that page then it shows user login. May be the reason that without refreshing the page it doesn't reload itself with cookies(login session). We want that either user can't go backward or if it go backward to registration page then the webpage already has details of login session. We are developing in MVC-Asp.NET

Please guide. Thanks in advance.

4
  • that's how browsers behave by design when you press the back button. You could however have a timed JS call to the server always running on the 1st page (even when the user is logged out) that returns a simple result signifying if the user is logged in and to alter what you see on the page appropriately/redirect/do whatever....or set a cookie and have the 1st page look for it....there are a few options Commented Nov 22, 2017 at 11:40
  • 2
    Possible duplicate of ASP.NET MVC how to disable automatic caching option? Commented Nov 22, 2017 at 11:47
  • stackoverflow.com/questions/20895489/… is also a good read on the issue. Commented Nov 22, 2017 at 11:49
  • @mjwills fair point - I jumped the gun there a little! Commented Nov 22, 2017 at 11:58

1 Answer 1

0

Add these attributes on your registration action method like.

[HttpGet] [OutputCache(NoStore = true, Duration = 0, VaryByParam = "None")] public ActionResult registration() { //your code here } 

SOURCE:Handling browser back button

Sign up to request clarification or add additional context in comments.

2 Comments

Also consider [OutputCache(NoStore = true, Duration = 0, VaryByParam = "*", Location = OutputCacheLocation.None)]
Thanks Hasan for your guidance. It resolve the issue. (y)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.