Как мы можем остановить представление веб-страницы после signout использование браузера назад

Как упомянутый Haacked, просто отбросьте контекст данных.

Вы, вероятно, не должны поддерживать контекст данных в течение долгого времени. Они разработаны, чтобы использоваться транзакционным способом (т.е. один контекст данных на атомарную единицу работы). Если Вы поддерживаете контекст данных в течение долгого времени, Вы рискуете генерации исключения параллелизма при обновлении устаревшего объекта.

5
задан Jacob 25 September 2009 в 09:57
поделиться

5 ответов

You have to set the following I guess

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

This will cause your page to post back also when the user presses the back button and so you're able to check whether he's still logged in and in case redirect him to some other place.

1
ответ дан 14 December 2019 в 13:41
поделиться

The problelm is the pages you can press back to have been cached. You can instruct your browser to ALWAYS fetch the pages from the server every time.

You will need to generate all of the following headers:

Pragma: no-cache
Cache-Control: max-age=1
Expires: Tue, 1 May 1985 01:10:00 GMT

The problem is not all browsers support all options so you have to include all of these headers to ensure all browsers don't cache your pages.

The other reason for needing all of these headers, is that in some cases even if the web browser is respecting the expires headers, there can be a misconfigured proxy server between you and the user that is still caching the pages.

In ASP you probably want to do something like this:

public void Page_Load() {
    Response.ExpiresAbsolute = DateTime.Now.AddDays(-1d);
    Response.Expires = -1500;
    Response.CacheControl = "no-cache";
    Response.Cache.SetETag(randomString);
}
3
ответ дан 14 December 2019 в 13:41
поделиться

You must disable cache.

public void Page_Load()
{
Response.Cache.SetCacheability(HttpCacheability.NoCache) 
...
}
1
ответ дан 14 December 2019 в 13:41
поделиться

How do you login/logout? a proper way of doing this is to save the user info into a session on login and clear that session on logout in every page's PageLoad method test if the session has valid infos or no, if not stop the page load. this way, when the user logout and click on back the session should be empty and it wont load, and you can then redirect to the login page. reply if you need some code

0
ответ дан 14 December 2019 в 13:41
поделиться
Другие вопросы по тегам:

Похожие вопросы: