0

I'm trying to set up a stripped down web server that passes all URL requests through to a single IHttpHandler, instead of trying to match the URL to the file structure of the server.

I've got the IHttpHandler in there, along with some custom modules, and they're responding as expected when I go directly to my domain, but if I access the site via something like:

http://mysite/some/random/url

I get a 404 file not found error.

I'd assumed removing one of these modules would probably cover it:

        <remove name="UrlRoutingModule-4.0" />
        <remove name="UrlMappingsModule" />
        <remove name="FileAuthorization" />
        <remove name="UrlAuthorization" />

But IIS is still trying to match the URLs to the server file structure. I've since removed every module I'm not using and it's still returning 404's.

I have actually done this before, but I can't seem to quite remember or find online quite how I got it working.

I'm now basically out of ideas - anyone?

Octopoid
  • 3,507
  • 5
  • 22
  • 43
  • 1
    runAllManagedModulesForAllRequests http://stackoverflow.com/questions/11048863/modules-runallmanagedmodulesforallrequests-true-meaning is big part of the puzzle. – Alexei Levenkov Apr 02 '15 at 19:38
  • Ah yes, thanks - I remember now I definitely had to use that previously to get it working. Using it alone hasn't resolved the problem however.. – Octopoid Apr 02 '15 at 19:40
  • 1
    If you want a _really_ stripped down webserver, you should look into [`Microsoft.Owin.SelfHost`](http://www.nuget.org/packages/Microsoft.Owin.SelfHost/)... – Brad Christie Apr 02 '15 at 23:15

1 Answers1

0

I added the runAllManagedModulesForAllRequests as per the suggestion from @Alexei Levenkov. While I remember definitely needing to do that, it didn't immediately solve it. After much fiddling about I found that IIS had set:

resourceType="Either"

on the handler. I tested changing it to File, and the problem was fixed for file type URLs, but of course not folder "style" ones. Changing it to:

resourceType="Unspecified"

Fixed the problem for all URLs.

Octopoid
  • 3,507
  • 5
  • 22
  • 43