简体   繁体   中英

Set handler for PDF in IIS

I developed an HttpHandler in order to count number of downloads for PDF files.

Now the problem is: How can I make IIS use my handler for PDF files?

For IIS 7 it does depend on which mode you are running IIS in. Microsoft has a great tutorial on this How to: Register HTTP Handlers which goes over all the different configuration scenarios but assuming you are running IIS 7 in integrated mode and your handler is a compiled binary you would need a web.config entry similar to the following:

<configuration>
  <system.webServer>
    <handlers>
      <add name="pdfCountHandler" verb="*" 
        path="*.pdf" 
        type="<your handler class name>, <your handler assembly name>" 
        resourceType="Unspecified" />
    </handlers>
  </system.webServer>
</configuration>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM