Why does the web API stop working on Azure sites if it runs on localhost.
Error Resource could not be loaded: the server responded with the status 404 (not found) or The resource you are looking for has been deleted, its name has changed or is temporarily unavailable. when pasting url into api in browser.
Note: I have never encountered this error, and I already have several sites already in the azure language, using Web Api attribute routing.
Webconfig
public static void Register(HttpConfiguration config) { config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); }
RouteConfig
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Cities", url: "Cities/{id}/{name}/{action}", defaults: new { controller = "Cities", action = "Index" } ); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); }
Global.asax
AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles);
Goggling showed that this is a common problem:
HTTP 404 Page not found in Web Api hosted in IIS 7.5
WebAPI DELETE request returns 404 error in Azure
Problems with routing WebApi and ASP.NET 4
https://stackoverflow.com/questions/15805471/using-windows-azure-websites-with-extensionlessurlhandler
Configure IIS methods for ASP.NET Web APIs on Windows Azure Websites
How ASP.NET v4 URLs Are Handled Without
Getting 404 from WebAPI on Windows Azure Websites
ASP.NET MVC 4 and web API in Azure - HTTP resource not found
MVC 4.5 web API routing not working?
UPDATE
After trying each method suggested in the links above, I deleted everything *. DLL from the solution, created a new MVC + Web API project and added * .dlls to the solution. The building and everyone worked as expected in the first place.