Click here to Skip to main content
15,901,205 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a page controller class in my application from which all the pages are inherited. and this class checks for the session and handle them.

Now I am facing an issue, if i log in to my application, and let say from page1 i click signout,

I will be redirected to Login.aspx if session was alive or to Login.aspx?SessionExpired if session has been expired.

But in both the cases, if i press Browser's back button, it simply redirects to Page1.

I have read and tried many articles including the following on CP.

Browser Back button Issue

and By Sandeep.

but still same is happening. I tried to clear cache of one page and than put user to logout from this page, than as expected, it was redirected to Login.aspx?QueryString, but when i push the back button from browser, again this page shows... :( even though I cleared its cache.

EDIT:

C#
protected void Page_Load(object sender, EventArgs e)
    {
//trying the above mentioned link code to clear the cache of current page.
Response.Buffer= true;
Response.ExpiresAbsolute=DateTime.Now.AddDays(-1d);
Response.Expires =-1500;
Response.CacheControl = "no-cache";

//calling the session handling controller class
//page is inherited from this page.
  base.Page_Load(sender, e);

//MY COde here
}




Can anybody give me some idea???
Posted
Updated 1-Nov-13 0:34am
v2
Comments
ridoy 1-Nov-13 4:22am    
so share your code here to see where the problem occurs.
Faisalabadians 1-Nov-13 5:34am    
The problem is your application allowing browser to cache its content, all you need to do is to stop caching. I have faced and resolved the issue, you are facing now. The fact was browser caches your application content which is enabled by default in mvc.
VICK 1-Nov-13 6:34am    
Question Edited along with code...

Hi Vick,

This can be handled using the HTTP module.

Create a HTTP Module File
Refer the HTTP Module File in your web.config
so when ever the application loads any page this maodule will be included in the Page life cycle process, so that you can check for the proper user authorization & Authenticatinthrough some session or cookie data if the user pressed logout, probably you may cleared those cookie / session values.

This HTTP Module File, will check for the values if the values are null then automatically redirects the page to Login.aspx or the page specified.


Note: HTTP Module File will be called before Page Load of all pages.

Implementing HTTP Module[^]

Thanks!
 
Share this answer
 
v2
Comments
VICK 1-Nov-13 6:26am    
i have a page controller class in my application from which all the pages are inherited. and this class checks for the session and handle them.

I already have this class implemented and it is working perfectly. .Main problem is if user logout from any page, than Browser back button leads to that page again, even though if user try to use any button or link on that page, then page gets post back, checked by this controller class and again redirected to login page with sessionexpired query string.

but on some of the pages, I am showing some data to user and dont want the browser back button to get redirected to that page, if user loggedout from that.
VICK 1-Nov-13 6:35am    
Difference is that I have made a separate class, added it in App_Code, and derived each page from this class and called it in page load.
[no name] 1-Nov-13 7:07am    
Yes, then can you just call for the common user check method, where the user is invalid then you automatically redirect to login page.

I will update you with other few options also. Can you share the code here.
VICK 5-Nov-13 6:24am    
But after redirection to login page. Browser will still keep last page in cache. and will show it on press of back button. :(
I have solved this by my self after adding the following code in my Page controller class and its working like a charm.

Thanks to YogeshwarBK108, from whom comment under the following article helped me alot.

Disabling browser's back functionality on sign out from Asp.Net


:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900