当前位置: 代码迷 >> ASP.NET >> OutputCache VaryByParam 怎么用代码来写
  详细解决方案

OutputCache VaryByParam 怎么用代码来写

热度:10125   发布时间:2013-02-25 00:00:00.0
OutputCache VaryByParam 如何用代码来写
<%@ OutputCache Duration="100" VaryByParam="location;count" %>
如上面这条是设置页面缓存的

那我不想在ASPX中写,我想在CS中写
那写法是怎么样的,谢谢

------解决方案--------------------------------------------------------
声明性的方法:


<%@ OutputCache duration="100" varybyparam="location;count" %>

程序化的方法:


Response.Cache.SetExpires(DateTime.Now.AddSeconds(100))
Response.Cache.SetCacheability(HttpCacheability.Public)
Response.Cache.VaryByParams["location;count"] = true