【问题标题】:How do I get a custom IHttpHandler to Be Capable of Handling Page cache?如何让自定义 IHttpHandler 能够处理页面缓存?
【发布时间】:2011-04-01 22:29:11
【问题描述】:

这是我的代码:

class HandlerTest : IHttpHandler,System.Web.SessionState.IRequiresSessionState
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.Write(DateTime.Now.ToString());

        context.Response.Cache.SetExpires(context.Timestamp.AddSeconds(10));
        context.Response.Cache.SetMaxAge(new TimeSpan(0, 0, 10));
        context.Response.Cache.SetCacheability(HttpCacheability.Public);
        context.Response.Cache.SetLastModified(context.Timestamp);
        context.Response.Cache.SetValidUntilExpires(true);
        context.Response.Cache.VaryByParams.IgnoreParams = true;

        context.Response.End();
    }
    public bool IsReusable
    {
        get { return true; }
    }
}

它不起作用。谁能告诉我该怎么做?

【问题讨论】:

    标签: .net ihttphandler page-caching


    【解决方案1】:

    我知道,当我删除这条线时,它是对的。

    context.Response.End();
    

    我希望这个问题可以帮助任何人。顺便说一下,我的英语很差。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-08
      • 2019-01-24
      • 2015-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-13
      • 2014-04-03
      相关资源
      最近更新 更多