views:

108

answers:

3

Hello, every one.

I am developing an asp.net web site & I am not using inbuilt authentication controls of asp.net.

I have created manually tables for users for site.

What I want is as follows

  • After logging in user can access the pages ( that is already done )
  • When user press sign out. ( user goes to specific page - example - default.aspx )
  • **Now when user press "back" button of browser It must not go to previous page. ** ( that is done in yahoo pages - I want to implement the same. )

Please inform me inform if it is duplicate question.

Thanks in advance for you humble help.

Sagar.

+1  A: 

To prevent users from seeing the previous page when pressing the back button you need to instruct the browser not to cache this page:

Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
Response.Cache.SetValidUntilExpires(false);
Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();

You could put this code in all authenticated pages, thus preventing them from being cached on client browsers.

Darin Dimitrov
sugar
+1  A: 

For a page not to be cached the browser needs to respond appropriately to caching instructions, but there is no guarantee that this will work on every browser! (An appropriately evil person could write their own browser to ignore caching information, or write a proxy to strip it out...)

So you can't get this to work 100% of the time, but you're always going to face the problem that a user can easily take a screenshot, print out a page, save a copy on their disk, etc. once you've fed a page to them anyway...

ninj
+1  A: 

the answer for you question is:

  • for When user press sign out. ( user goes to specific page - example - default.aspx ) you can add a LinkButton as Signout link and in the click event handler you can write Response.Redirect("Default.aspx");

  • for Now when user press "back" button of browser It must not go to previous page //add the following code to your code behind of the page

    protected override void OnPreRender(EventArgs e)

    {

     base.OnPreRender(e);
    string strDisAbleBackButton;
    strDisAbleBackButton = "<script language="javascript">\n";
    strDisAbleBackButton += "window.history.forward(1);\n";
    strDisAbleBackButton += "\n</script>";
    ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "clientScript", strDisAbleBackButton);
    

    }

refer to csharpdotnetfreak.blogspot.com

peacmaker