zoukankan      html  css  js  c++  java
  • 在Asp.net项目中禁止浏览器缓存页面

    方法1:在asp.net服务器端页面中添加如下代码段(只是作用于某个特定的页面)

    <%
        Response.Buffer = true;
        Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
        Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
        Response.Expires = 0;
        Response.CacheControl = "no-cache";
        Response.Cache.SetNoStore();
    %>

    方法2:在Global.asax.cs文件中的特定方法中加入如下代码段(作用于整个工程)

    protected void Application_BeginRequest(Object sender, EventArgs e)
    {
        HttpContext.Current.Response.Cache.SetNoStore();
    }

    方法3:在服务器端页面对应的隐藏代码文件中加入如下代码段(作用于特定页面)

    Response.Buffer=true;
    Response.ExpiresAbsolute=System.DateTime.Now.AddSeconds(-1);
    Response.Expires=0;
    Response.CacheControl="no-cache";

  • 相关阅读:
    jsonrpc
    第十章:多线程
    第九章:IO流
    第八章:集合
    第七章:常用类
    第六章:异常机制
    第四章:数组
    第三章:流程控制语句
    第二章:数据类型和运算符
    第五章:面向对象4
  • 原文地址:https://www.cnblogs.com/KnowledgeSky/p/3184521.html
Copyright © 2011-2022 走看看