Click here to Skip to main content
15,905,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i clicked the logout button then i cleared all session value using session.clear(),session.abandon() but i clicked back button in INTERNETEXPLORER it directly go to previous pages.how to handle this type of error in asp.net,c#.net

Here how we use sessions..?
Posted

You can write in the previous pages something like
if (Session["User"] == null)
Response.Redirect("sign-in.aspx");
 
Share this answer
 
Check if the session cleared or not or check the session count when u clicking on back button if the session count is zero then redirect to corresponding page
 
Share this answer
 
Comments
venkatrao palepu 9-Nov-10 0:05am    
Here session count is zero.
I wrote if(session.count==0) redirect to login page
but click on back button in INTERNET EXPLORER its goes to Homepage

anyone plz help me....
jim lahey 9-Nov-10 5:04am    
Like I said in my answer, you need to make the page expire so that the browser doesn't load it from the cache and is forced to run the page again, including your code that redirects to the login page.
I remember having this problem, it's caused by only IE for a change not executing the page on using the back button instead the last cached version of that page is displayed. our fix was to set the cache expiry of the page like this:

//NOTE: This is needed in conjunction with Session.Abandon() on logout or the back button click
//sends you straight back to the logged in view 
Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();


hope it helps.
 
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