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

前端 未结 16 2025
感情败类
感情败类 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条回答
  •  萌比男神i
    2020-12-01 06:20

    From aspdev.org:

    Add the following line on top of the Page_Load event handler and your ASP.NET page will not be cached in the users browsers:

    Response.Cache.SetCacheability(HttpCacheability.NoCache)
    

    Settings this property ensures that if the user hits the back-button the content will be gone, and if he presses "refresh" he will be redirected to the login-page.

提交回复
热议问题