This project has moved. For the latest updates, please go here.

SystemWeb doesn't process all requests by default

Nov 23, 2013 at 3:43 PM
Hey guys ;)

It appears that requests whose URL contains an extension - or seems to - are not correctly processed by the OWIN pipeline when IIS is used, even with runAllManagedModulesForAllRequests set to true.
Although this behavior could be seen as an easy and efficient way to let IIS serve static files, it may break legitimate uses.

For instance, OData uses specific URLs to expose derived entity sets which can't be served by OWIN because they are interpreted as static resources by IIS.
Thus, asking for http://localhost:56095/EntitySet/Namespace.DerivedEntity or http://localhost:56095/EntitySet/Namespace.DerivedEntity() causes the request to be processed by StaticFileModule, whereas http://localhost:56095/EntitySet/Namespace.DerivedEntity/ is correctly processed by OWIN.

The easiest way I found to work around that is to use the OwinHttpHandler with a path set to "*", but I think it would be great if OwinHttpModule could work OTB.

You can easily reproduce this bug using an empty IIS-hosted OWIN app, registering a default handler (or the amazing welcome page) and opening these URLs in your browser to see whether they are correctly processed by the registered handler.

Nov 23, 2013 at 3:58 PM
IIS's native static file module is very greedy. There are two steps required to override it:
  1. Enable runAllManagedModulesForAllRequests, as you have done.
  2. Add app.UseStageMarker(PipelineStage.MapHandler); at the end of your OWIN pipeline (or at least after the component you're having difficulty with). Requires "using Microsoft.Owin.Extensions".
Alternatively you could remove the native static file module.
Marked as answer by PinpointTownes on 12/17/2013 at 3:48 AM
Nov 23, 2013 at 4:05 PM
Amazing, it works like a charm... thank you very much!

I can't imagine how useful it could be to mention it somewhere in the documentation ;)