【问题标题】:HTTPHandler for all files in directory目录中所有文件的 HTTPHandler
【发布时间】:2012-07-17 08:09:59
【问题描述】:

我创建了一个 HTTPHandler 来处理某个文件夹(“文件”)中的所有文件。当我从 Visual Studio 在本地运行它时,它工作正常。但是,当我在服务器上部署它(IIS 7,经典模式)时,处理程序不会针对 pdf、jpg、gif 等类型的文件触发(尽管请求扩展名为 .aspx、.axd.. .etc 确实有效)。

我应该如何配置 web.config 来处理这些文件。我在 Files 文件夹中放置了一个 web.config 文件,其中包含以下内容:

<configuration>
    <system.web>
      <httpHandlers>
        <add verb="*" path="*.*" type="MyProject.Web.FileSecurityHandler, MyProject.Web"/>
      </httpHandlers>
    </system.web>
</configuration>

请帮忙...

【问题讨论】:

    标签: httphandler


    【解决方案1】:

    在您的 HTTPHandler 标记中再添加一个元素,用于特定文件类型,例如

    <configuration>
    <system.web>
      <httpHandlers>
        <add verb="*" path="*.*" type="MyProject.Web.FileSecurityHandler, MyProject.Web"/>
       <add path="*.jpg,*.jpeg,*.bmp,*.tif,*.tiff" verb="*" type="NameofYourHandler" />
      </httpHandlers>
    </system.web>
    </configuration>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-23
      • 2016-11-07
      • 1970-01-01
      • 1970-01-01
      • 2023-01-04
      • 2021-01-05
      • 1970-01-01
      • 2012-11-14
      相关资源
      最近更新 更多