【问题标题】:No caching and Logout in C# / asp.Net 3.5C# / asp.Net 3.5 中没有缓存和注销
【发布时间】:2012-05-11 06:02:35
【问题描述】:

我在我的 masterpage.page_load 中有一个注销,我在其中禁用了缓存,如下所示:

Response.ExpiresAbsolute=DateTime.Now.AddDays(-1d);
Response.Expires =-1500;
Response.CacheControl = "no-cache";

Response.Redirect("Login.aspx");

如果页面刷新并且您已注销,则注销功能可以正常工作,然后转到登录页面。但是,如果您退出并点击返回按钮,您仍然可以转到上一页。

我该如何解决这个问题?

【问题讨论】:

    标签: c# asp.net .net caching disable-caching


    【解决方案1】:

    你可以在Page_Load活动中试试这个。

    Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Page.Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
    Page.Response.Cache.SetNoStore();
    

    有关更多信息,您可以阅读此内容。 Setting the Cacheability of a Page

    【讨论】:

    • 感谢我没有缓存,它仍然无法正常工作,但我会查看链接中的注释
    • @chris: 这也是一本好书stackoverflow.com/questions/10525172/…
    • @chris:如果您对答案感到满意,请不要忘记接受它作为答案。它将帮助未来的读者。
    • 很好,终于成功了!它在 IE 中与其他代码一起工作,但不在 FF 中,但现在两者都在工作
    猜你喜欢
    • 1970-01-01
    • 2021-11-21
    • 1970-01-01
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-15
    相关资源
    最近更新 更多