zoukankan      html  css  js  c++  java
  • 通过编程为ASP.NET页面设置缓存

    ASP.NET引入的页面缓存机制,对于大型应用程序开发相当关键。我们可以通过页面声明的方式进行配置

    <%@ OutputCache Duration="10" VaryByParam="none" %>

    还支持在运行时通过编程来设置

    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Cache.SetExpires(DateTime.Now.AddSeconds(10));//这是相对时间,即10秒之后过期
        Response.Cache.SetCacheability(HttpCacheability.Public);
        Response.Cache.SetValidUntilExpires(true);//这句是必须的,否则没有办法实现缓存效果
        Response.Write(DateTime.Now.ToString());
    }
    
  • 相关阅读:
    ASP.NET Core 从入门到精通-资源收集导航
    【5分钟系列】计算机系统结构的定义
    C#反射与特性(九):全网最全-解析反射
    C#反射与特性(七):自定义特性以及应用
    C#反射与特性(六):设计一个仿ASP.NETCore依赖注入Web
    C#反射与特性(五):类型成员操作
    C#反射与特性(四):实例化类型
    C#反射与特性(三):反射类型的成员
    C#反射与特性(二):探究反射
    安卓TabLayout+ViewPager实现切页
  • 原文地址:https://www.cnblogs.com/chenxizhang/p/1282719.html
Copyright © 2011-2022 走看看