Search code examples
iisasp.net-web-apiowinkatanatopshelf

How does Katana/IIS handle conflicts. WebApi in WinService and website in IIS - who wins?l


I have a IIS configured with a lot of websites. Now I want to install a WebApi hosted with OWIN/Katana in a Windows Service (using topshelf). Could my WebApi be using the same port as IIS?

Will this work? What if I use the same name - who wins?

Thanks for any help - I'm a bit confused here.

Larsi


Solution

  • Theoretically it's possible to do it.

    Windows allows to reserve URLs for different services, so that they can listen on a particular url. Once the reservations are done, and the applications start listening for requests, the HTTP Server API routes the incoming requests to the different services. Here is an explanation on how that happens:

    Routing Incoming Requests

    With Web API it's very easy to setup the service to listen on a concrete URL, and will not interfere with the routing of other URLs.

    The problem is in IIS. IIS only allows you to setup a site on a root URL, instead on a concrete URL path. There is no concrete documentation on how this reservation is done. But you can see it your self using netsh:

    1. open a command prompt and run netsh
    2. you'll see netsh> prompt
    3. type http. The prompr should now read netsh http>
    4. type show urlacl

    This will show you the complete list of URL reservations for all the services in the machine. NOTE, you can dump the output to a file running this from the command line: netsh http show urlacl > c:\users\jotabe\documents\urlacls.txt

    With all this information you can setup IIS and a Web API service, check the registrations created by them, and, according to the rules on the linked document seeif what you want to do will work or not.