Iis – Handler mapping on IIS / OWIN /Nancy for a CSV file

csvhandler-mappingsiis

I've an issue with IIS and OWIN/Nancy, here is the setup of our server :

  • Windows Server 2012 R2
  • IIS 8.5
  • OWIN with Nancy (middleware)
  • ASP.NET 4.5
  • Application developed in F#.

I want to download a .csv file with an URL like this :

https://www.myserver.com/Reports/Current/2014-11-10.csv

This file must be handled by Nancy and not by IIS.

So I think that I need to add a handler mapping to OWIN/nancy on IIS like this :

 <handlers>
      <add name="CSV files" path="/Reports/Current/*.csv" verb="GET" type="Microsoft.Owin.Host.SystemWeb.OwinHttpHandler" resourceType="File" preCondition="integratedMode" />
 </handlers>

But it still doesn't work, I've always a 404 error when I'm trying to download this CSV file.

Does anyone have an idea to help me ?

Best Answer

The solution is not to add a "CSV" handler, but to configure the ExtensionlessUrlHandler-Integrated-4.0 script map to handle paths with extensions. You can do this by changing the path from *. to *. This will pass all requests to Nancy (in your case), irrespective of whether they have an extension.