views:

197

answers:

3

I have created a website. I login with username and password and after authenticating i redirect the user to Home Page. When the user clicks Logout, they are redirected to the Login Page. But after this when i click the BACK button on the browser, it again goes back to the Home Page with that user's login credentials. I have used Session["username"]=null in the Page_Load function of Home Page. How to avoid going back to the Home Page when the BACK button is clicked by the User??

A: 

Most of the times browser back button did not get data from server it usually get it form browser cache. I think you should try removing page from browser cache on logout event,it will solve your problem automatically.

try this http://forums.asp.net/t/1329607.aspx

Regards.

Shoaib Shaikh
Thanks a lot!!!!!!! It's Working :-)
Vinodh Kumar
+1  A: 

Hi Vinodh,

behind logout button code body use FormAuthentication.SignOut()

it remove tickets from authentication.

the page render on clicking back button but when user perform any task on that page and click on button or any thing which take postback not allow him to submit anything and redirect him to desire page.

if you got your answer click my answer and vote my answer,thanx

Emaad Ali
while if you are using sessions then you can check the session value is it null or not.if null then redirect to desire page.perform that work in pageload.
Emaad Ali
+1  A: 

Try adding the following code to your homapage Page_load

HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetNoStore();
Shoban
Thanks a lot!!!!!!! It's Working :-)
Vinodh Kumar
then please accept the answer for this and other questions of yours
Shoban