Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
After click the back button , it redirects to login window, if i click the back button the browser it goes to the previous page, I cleared the session for all the variables in asp.net with c#, and added the following lines to clear cache still it goes to the previous page, please help it very urgent
Posted
Comments
suhailnoorpawane 21-Dec-11 23:39pm    
Please check the url is it Returning some Return Url or something.

Do reply

Thanks and regards
Praveen Kullu 21-Dec-11 23:45pm    
Which lines did you add?

There are different approaches to avoid this. The best and secured approach is on page load check the session value. If it exists go with functionality other wise redirect to the login page.
if (!string.IsNullOrEmpty(Convert.ToString(Session["username"])))
        {
            //continue logic
        }
        else
        {
            Response.Redirect("login.aspx");
        }
 
Share this answer
 
write this code in logout link button

XML
Session.Abandon();
       Response.Write("<script>window.top.navigate('../login.aspx')</script>");


the above script disables the back button of the internet explorer

or else you can write like this
in each page in Page_Load event
C#
protected void Page_Load(object sender, EventArgs e)
    {
        if (Session.Count > 0)
        {
            //show this page
        }
        else
            Response.Redirect("Login_page.aspx");
    }


Hope this will help you
 
Share this answer
 
Try the javascript method:

In the <head></head> section add the following javascript code:

XML
<script type="text/javascript" language="javascript">
function noBack()
{
window.history.forward()
}
noBack();
window.onload=noBack;
window.onpageshow=function(evt){if(evt.persisted)noBack()}
window.onunload=function(){void(0)}
</script>

call this function using:

body onload="noBack();


source:http://forums.asp.net/t/1452128.aspx/1[^]
 
Share this answer
 
 
Share this answer
 
This is not depend on Session.

This is the setting of browser..

When you click on back button then Page_Load event will not fire.

Hence just use javascript to Move forward only..
 
Share this answer
 
there is no command to stop previous or forward page navigation
while opening your page do menubar & toolbar display no. so the user can't move previous or forward page.
 
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