【问题标题】:Add web.config static content settings for custom httphandler为自定义 httphandler 添加 web.config 静态内容设置
【发布时间】:2011-03-06 09:05:05
【问题描述】:

我有一个自定义的 httphandler,它为来自虚拟文件系统的静态文件提供服务。如果我像下面这样配置静态内容部分,我希望这些设置适用于我通过处理程序提供的静态文件。我想我需要将设置添加到我自己的响应中,还是有其他方法?我的处理程序实现了 IHttpHandler 接口。

  <location path="Storage">
    <system.webServer>
      <handlers>
        <clear />
        <add name="StaticFile" path="*.jpg" verb="*" type="Stormbreaker.Web.StaticFileHandler, Stormbreaker" />
      </handlers>
      <staticContent>
        <clientCache httpExpires="Sun, 29 Mar 2020 00:00:00 GMT" cacheControlMode="UseExpires" />
        <mimeMap fileExtension=".jpg" mimeType="image/jpeg" />
      </staticContent>
    </system.webServer>
  </location>

【问题讨论】:

    标签: c# httphandler iis-7.5 cache-control


    【解决方案1】:

    我相信 staticContent 只会影响 IIS 附带的 StaticFileHandler。 IIS 无法知道您的处理程序提供静态文件,因此您需要在您的处理程序中添加您自己的这些标头,但您可能希望通过 web.config 将其配置为可配置,并使用其自己的部分以供将来更改。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-13
      • 1970-01-01
      • 1970-01-01
      • 2012-01-20
      • 1970-01-01
      • 2016-05-11
      • 1970-01-01
      相关资源
      最近更新 更多