HTTPHandler用于目录中的所有文件

时间:2012-07-17 08:10:00

标签: httphandler

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

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

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

请帮忙......

1 个答案:

答案 0 :(得分:0)

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>