Search code examples
asp.net.nethttphandler

ASP .NET httphandler for .pptx files not working in web.config


All of the handlers below work except the one for .pptx files. Has anyone else had this problem?

Here is what is in the web.config:

<httpHandlers>
      ...
  <add verb="*" path="*.pdf" type="System.Web.StaticFileHandler" validate="true"/>
  <add verb="*" path="*.docx" type="System.Web.StaticFileHandler" validate="true"/>
  <add verb="*" path="*.doc" type="System.Web.StaticFileHandler" validate="true"/>
  <add verb="*" path="*.pps" type="System.Web.StaticFileHandler" validate="true"/>
  <add verb="*" path="*.ppt" type="System.Web.StaticFileHandler" validate="true"/>
  <add verb="*" path="*.pptx" type="System.Web.StaticFileHandler" validate="true"/>
</httpHandlers>

Solution

  • If the problem is restricting access to the .pptx file type, try doing the following: Create a custom mapping in IIS by opening the web site properties in IIS, navigating to Configuration -> Mappings -> Add and then adding the .pptx extension. This is necessary because, by default, .NET does not protect non Asp.NET files.

    Further information: How to restrict the access to a given folder for a specific role