Click here to Skip to main content
15,880,725 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
Dear Friends

I have a query related security and restrict webpage access after logout. And one more thing, sometimes user copy the URL and paste into another browser and it works with some error.

But I want when user do these types of things then it will automatically redirect to login page. Please help me out as soon as possible.

Thanks in advance to all.
Posted
Updated 21-Apr-18 2:09am
v2

-To Disable back button try this:
1.Write this code in master page in page load event
HTML
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();

and
2.Write this code in login page in head section
HTML
<script type="text/javascript">
window.history.forward(-1);
</script>


-To restrict the User by accessing pages using URL try this:
After a user is authenticated, create a session object indicating that. In every page check if that session object has the authenticated value.
Something like:
C#
//In the login page, after user is authenticated
Session["validated"] = true;
 
//In every page that requires authentication, On page load event, check
if(Session["validated"] == null)
    Response.Redirect("Login.aspx");
else
    //do what you want here.
 
Share this answer
 
Have a look at this tip: Browser back button issue after logout[^]
 
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