开发者

Clicking the back button after logging out still renders my password protected page

开发者 https://www.devze.com 2023-03-07 05:30 出处:网络
I\'m writing a Web Application using ASP.NET 4.0 and C#. In my application when I logout the page redirects to the Default page. But when I click the back button in m开发者_运维问答y browser, it goes

I'm writing a Web Application using ASP.NET 4.0 and C#. In my application when I logout the page redirects to the Default page. But when I click the back button in m开发者_运维问答y browser, it goes back to the Web page that I was working even though I'm logged out.

How do I stop it doing this?


You could set cache headers in authenticated pages to avoid them being cached downstream on the client. Here's an article you may take a look at.

So you could set the following headers on authenticated pages:

Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();

This could also be done in a custom HTTP module to avoid repeating the code in all pages.

0

精彩评论

暂无评论...
验证码 换一张
取 消