新闻最终页生成了静态文件,包含两部分,一个是主页面,一个是评论,它通过iframe包含在主页面里。当添加一条评论时,提交数据到另一页处理完后,用Response.Write(Request.ServerVariables("HTTP_REFERER"))返回到本页,郁闷的是,本页的评论竟然没有更新,但是看评论静态页面时,它已经重新生成,手动点击刷新后,新添加的评论才能显示出来。求助是什么原因呢?如何不手动点击刷新,也能自动刷新出新增评论来?

解决方案 »

  1.   

    ie里的缓存没有刷新,在评论页面里加上这段代码
    /// <summary>
    /// 清空浏览器客户端的缓存
    /// </summary>
    public static void ClearClientPageCache()
    {
    HttpContext.Current.Response.Buffer=true;
    HttpContext.Current.Response.Expires = 0;
    HttpContext.Current.Response.ExpiresAbsolute=DateTime.Now.AddDays(-1);
      HttpContext.Current.Response.AddHeader("pragma","no-cache");
      HttpContext.Current.Response.AddHeader("cache-control","private");
      HttpContext.Current.Response.CacheControl="no-cache";
    }