I'm trying to deploy a WebAPI project to Azure.
It works locally. When I Publish
it to Azure, I get 404 on the controller routes.
Looking at the logs, I see the routes are being handled as static files, instead of going through my controllers.
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
Requested URL http://xxxxx:80/api/studies
Physical Path D:\home\site\wwwroot\api\studies
Logon Method Anonymous
Logon User Anonymous
My Global.asax is:
protected void Application_Start()
{
GlobalConfiguration.Configure(WebApiConfig.Register);
}
And my WebApiConfig.Register is:
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
I've looked at similar questions and tried tweaking my Web.config to no avail. It currently looks like this (relevant part only):
<system.webServer>
<httpErrors existingResponse="PassThrough"/>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
</modules>
<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" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
By the way, I'm on Entity Framework 6 and not using MVC, just straight up WebAPI.
Somehow my Global.asax
got excluded from the project, so the route mapping never happened.
I had the same issue. nothing else worked until changing my web config to look like this solved it for me
<handlers>
<remove name="WebDAV" />
<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" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
Have you checked all the necessary Windows Features for your server? Maybe some features are missing from IIS, for example: Internet Information Services - World Wide Web Services - Application Development Features - ASP.NET. You can find and check which features are installed on your machine by going to Windows Features (or going through the Server Manager if you're on a Windows Server).
If that is not your problem, it can sometimes be that ASP.NET is not installed properly. You can re-install ASP.NET by following this article: http://support.microsoft.com/kb/2736284 (it depends on your operating system).
User contributions licensed under CC BY-SA 3.0