404 with iis7 asp.mvc doc and pdf files in folder

2019-09-17 05:19发布

问题:

I have got folder "binaries" in my web application. I would like to download pdf and doc (static ontent) files from that direcotory but when i try to get them i have got error 404. I tried to set up static module for *.doc and *.pdf but it not works.

回答1:

StaticFileHandler should work. I had the same problem with *.bz2 files and I have solved it using StaticFileHandler. You can find configuration I used below:

<httpHandlers>
      <remove verb="*" path="*.asmx"/>
      <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
      <add verb="*" path="*.mvc" validate="false" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add verb="*" path="*.bz2" type="System.Web.StaticFileHandler" validate="false" />
</httpHandlers>


回答2:

I converted my directory with binaries (docs, pdf etc.) to application and this resolved my problem with 404 and static files.