catch back button in web browser
Hi guys,
Is there a way to catch the back button in web browser?
Let's say a user logs in then he goes to the viewdata.aspx after which he then goes back to the main page and logs out.
What i want now is whenever he hits the back button he will then be redirected to the login.aspx.
I tried using sessions and it works if only the user types in the url but if hits the back button he can still view the cached data.
I don't want to disable the caching of my webforms since it (i think) i slows the web page and also because it prevents the user to view data that is being cached since the user is still log on.
Thanks and God bless
Re: catch back button in web browser
It doesn't "slow" the web page, it will make sure that the page is loaded from the server each time, but the difference is minimal, as that is the right solution. This way as long as the user is logged in, he can view what's on viewdata.aspx.
Re: catch back button in web browser
Actually the user can not view the page that he visited whenever i disable the caching. it automatically expires whenever the user hits the back button eventhough he is still log in. I just like to trap the back button or the forward button, everything else is ok since i am using session. i only disable the caching part on the pages that requires update and insert since these pages requires click event to process transactions. Thanks
Re: catch back button in web browser
You can introduce a "Thank you for submitting that information" page which does a javascript location.replace so that when the user clicks back, he ends up on the thank-you page which redirects him forward anyways.
You can't really 'catch' a back button event as it is a browser event, not a server side one.
Re: catch back button in web browser
but can i have little sample.
Thanks
Re: catch back button in web browser
Is what I've described really that difficult? Can you at least perform a few searches and find some code that you try to put together? (And show us where you're stuck)
Re: catch back button in web browser
Quote:
Originally Posted by mendhak
Can you at least perform a few searches and find some code that you try to put together? (And show us where you're stuck)
that's why maybe i'm here to do a research. thanks anyway