Active Server Pages Programming (ASP)/Prevent going back to previous page
Expert: Srini Nagarajan - 5/18/2005
QuestionI dont seem to be able to use the response.expires. What is it and how does it work ? is it the property that sets the timeout?
-------------------------
Followup To
Question -
I believe a million people have already asked what i'm about to ask, but i don't seem to be able to find the answer online.
I'm building a .NET based login pages and was wondering how do i prevent users from going back to the previous page by clicking the back button. When i've logged out of my secured pages, using FormsAuthentication.SignOut() , i'm still able to reach the secured pages by clicking on back. I've noticed that some other secure sites like yahoo mail and hotmail have done it successfully. When user click on the back button, a message saying ' the session has already expired' kind of stuff.
How do you achieve that using ASP.NET ?
Answer -
Hi
Sorry I was away...
You can put this on the page
Response.Expires = 0
Response.Cache.SetNoStore()
Response.AppendHeader("Pragma", "no-cache")
this will not cache the page.
Happy Programming!!
-Srini
AnswerHi
I am Back!... Sorry for the delay in reply. I had a long business trip to Florida (did'nt goto any park! :( )
Here is the URL explaining how to use the response.expires
http://www.dotnet247.com/247reference/msgs/53/266781.aspx
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/passport25/NET_
Thanks for your patience!
Happy Programming!
-srini