• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
向往
博客园    首页    新随笔    联系   管理    订阅  订阅
解决客户端缓存问题 and 一般处理文件里 使用session

Response.Cache.SetCacheability(HttpCacheability.NoCache);
        这一行的代码可以让客户端不使用缓存,而从服务器重新读取

 

 

 

//

<%@ WebHandler Language="C#" Class="reg" %>

using System;
using System.Web;
using System.Web.UI;
using System.Web.SessionState;

public class reg : IHttpHandler, IRequiresSessionState
{
   
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        string strcode = context.Request.Cookies["CheckCode"].Value;
        //string strcode = "";
        //if (context.Session["CheckCode"] != null)
        //{
        //    context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        //    strcode = context.Session["CheckCode"].ToString();
        //}
       
        context.Response.Write(strcode);
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}

posted on 2011-10-21 22:42  向往  阅读(373)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3