I created a WebAPI(2.2) project being hosted in IIS, started with a blank Web project and then added WebAPI controllers and it's dependencies, it is a very simple project with one controller and a couple of delegating handlers.
The problem is, whenever I set the application as an IIS website of its own (iis website pointed to the project's root) or as a web application inside a website that has no application at it's root (say inetpub\wwwroot) the API works just fine, but whenever I try to host it as a web application inside of a website that has an application at it's root, then any call to the API returns a 404 Not Found and the IIS error says that the call is being handled by the "StaticFile" handler even when I add the ExtensionlessUrlHandler in the web.config for the path "*."
+ Sites
|
--+ WebApp1 (points to c:\apps\webapp1, a .Net web application)
|
--+MyAPI (ponts to c:\apps\MyAPI, the API in question) DOESN'T WORK
|
|
--+ DEV (points to c:\inetpub\wwwroot, an empty folder)
|
--+MyAPIAgain (points to c:\apps\MyAPI, the API in question) WORKS
|
|
--+MyApiWebSite (points to c:\apps\MyAPI, the API in question) WORKS
I have done some googling about the issue and the solutions I've found all come down to two: registering .net in iis (which is not the case as the api already runs in one setup, that would prevent MyAPIAgain and MyApiWebSite from working) and overriding the handlers using the following in the web.config
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<modules>
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
</modules>
</system.webServer>
None of which have done the trick. Any ideas?