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.