ASP.net里不让浏览器缓存代码和Session使用注意事项

时间:2023-03-10 05:27:48
ASP.net里不让浏览器缓存代码和Session使用注意事项

//不让浏览器缓存

            context.Response.Buffer = true;

            context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);

            context.Response.AddHeader("pragma", "no-cache");

            context.Response.AddHeader("cache-control", "");

context.Response.CacheControl = "no-cache";

//一般处理文件(ashx)中使用Session需要继承IRequiresSessionState

IRequiresSessionState