I have a Web Api application. It works perfectly well when I tested it using the VS 2010 debugging dev server. But I now deployed it to IIS 7.5 and I am getting a HTTP 404 error when trying to access the application.
Here is my web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-FlowGearProxy-20123141219;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="true" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
</configuration>
For me the problem was the root site was configured to use a .NET 2.0 app pool, and my application within that site was .NET 4.5.
I created a new site with a .NET 4 app pool and placed my application at the root of that - and that worked fine.
For me the solution was removing the following lines from my web.config file:
I noticed that VS had added them automatically, not sure why
Please make sure the application pool is in Integrated mode
And add the following to web.config file:
What kind of HTTP request are you making?
This is a slightly left-field answer but have you tried removing the IIS default error page for 404 to check what your API is actually returning?
I had an issue whereby I wanted a controller method to return a 404 when I POSTed the wrong id to it. I found that I was always getting the IIS 404 "File or directory not found" page rather than the HTTP response from my API. Removing the default 404 error page resolved the problem.
Different issue but you never know it may help ;)
Don't forget to deploy global.asax
It got resolved for me, when I enable checkbox for UrlRoutingModule-4.0:
IIS Manager > Modules > select UrlRoutingModule-4.0 > Edit Module > check the check-box "Invoke only for requests to ASP.NET applications or managed handlers".