Is there a way to keep a page from rendering once a person has logged out but hit the “back” button?

前端 未结 16 2041
感情败类
感情败类 2020-12-01 05:18

I have some website which requires a logon and shows sensitive information.

The person goes to the page, is prompted to log in, then gets to see the information.

16条回答
  •  孤城傲影
    2020-12-01 06:22

    The short answer is that it cannot be done securely.

    There are, however, a lot of tricks that can be implemented to make it difficult for users to hit back and get sensitive data displayed.

    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.Cache.SetExpires(Now.AddSeconds(-1));
    Response.Cache.SetNoStore();
    Response.AppendHeader("Pragma", "no-cache");
    

    This will disable caching on client side, however this is not supported by all browsers.

    If you have the option of using AJAX then sensitive data can be retrieved using a updatepanel that is updated from client code and therefore it will not be displayed when hitting back unless client is still logged in.

提交回复
热议问题