As with many people running a Web API through Visual Studio 2013 works fine; however when trying to get this running on an IIS 7.5 web server it does not work; I get the standard IIS 404 when trying to access my routes. It appears that with the web.config
created by Visual Studio, the Web API will not work without some additional web.config voodoo of which I cannot figure out. Is there a definitive answer to get a Web API up and running on IIS 7.5? Is this
KB an answer?
None
0 Points
2 Posts
Web.config Voodoo
Sep 09, 2014 02:35 PM|ideka|LINK
As with many people running a Web API through Visual Studio 2013 works fine; however when trying to get this running on an IIS 7.5 web server it does not work; I get the standard IIS 404 when trying to access my routes. It appears that with the web.config created by Visual Studio, the Web API will not work without some additional web.config voodoo of which I cannot figure out. Is there a definitive answer to get a Web API up and running on IIS 7.5? Is this KB an answer?
I have seen references indicating:
<handlers>
<remove name="WebDAV" />
</handlers>
<modules>
<remove name="WebDAVModule" />
</modules>
Doing this gives me an IIS 404 errror.
I have seen references indicating:
<modules>
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
</modules>
Doing this gives me an IIS 404 errror.
I have seen references indicating:
<modules runAllManagedModulesForAllRequests="true" />
Doing this gives me an IIS 404 errror.
I have seen references indicating:
<handlers>
<remove name="svc-Integrated-4.0" />
<add name="svc-Integrated-4.0" path="*" verb="*" type="System.ServiceModel.Activation.ServiceHttpHandlerFactory, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
Doing this gives me a .NET 404 error...getting closer
I have seen references indicating:
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
Doing this gives me an IIS 404 errror.
All-Star
30411 Points
3628 Posts
Re: Web.config Voodoo
Sep 11, 2014 05:59 AM|Fuxiang Zhang - MSFT|LINK
Hi ideka,
Welcome to asp.net forum.
As for your issue, please try to add below section to web.config file.
Similar issue you can follow below:
http://stackoverflow.com/questions/705229/diagnosing-404-errors-on-iis-7-and-asp-net-mvc
http://stackoverflow.com/questions/9703090/mvc-4-web-api-iis7-5-http-404-page-not-found
Thanks.
Best Regards!
None
0 Points
2 Posts
Re: Web.config Voodoo
Sep 11, 2014 08:00 AM|ideka|LINK
Thanks for the reply. I finally got it working with a properly configured web application and the following in the web.config.
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<!-- ADDED -->
<remove name="svc-Integrated-4.0" />
<add name="svc-Integrated-4.0" path="*" verb="*" type="System.ServiceModel.Activation.ServiceHttpHandlerFactory, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>