Tuesday, July 28, 2009

How to prevent user to browse to previous page everytime after logout in ASP.NET using c#. Please help, urgent

The language using is ASP.NET in c#, try to using session but cannot work. Please give me some code example. Thanks a lot.

How to prevent user to browse to previous page everytime after logout in ASP.NET using c#. Please help, urgent
You'd think you could capture the back button event in ASP.net, but that isn't so. But there's a couple tricks you can use.


The first one is to use a javascript like this one:





%26lt;script language="JavaScript"%26gt;


%26lt;!--


javascript:window. history.forward(1);


//--%26gt;


%26lt;/script%26gt;





It will send the user forward one page, so hitting back brings them right to where they are.





Another way is to create a blank page. For example if you have a 4 page site, and the 4th page is the logout screen. Add a 5th page with nothing on it. When the user goes from page 3 to page 4, they hit page 5 first. So the "Next" button on page 3 says Response.Redirect("Page5"). The only thing in Page 5 is in the page load event, which says Response.Redirect("Page4"). It goes by so fast the user never sees it and doesn't know he went through one page on the way to another.


So now the user is on page 4 and hits the back button to go to page 3, but it actually loads Page 5, which immediately sends the user to page 4.





Try both of those and see if one suits you.
Reply:the easiest way would be to have a javascript tag to go forward as follows: This is more of a pseudo code, so you can expand on it.





%26lt;html%26gt;%26lt;head%26gt;


%26lt;script language="javascript"%26gt;


href.location=go.forward();


%26lt;/script%26gt;





%26lt;/head%26gt;%26lt;/html%26gt;


No comments:

Post a Comment