Web API 2 not working (404)
For me routing attributes were not working with WebAPI because I had the URL Rewrite module installed in my web.config. Somehow the global routing templates were working with that in place but not the routing attributes above each web method. I removed the <rewrite>
section from within the <system.webServer>
section in web.config and the routing attributes started working.
please update your global.asax like here:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
and change [Route("~/api/sendemail")]
to [Route("/api/sendemail")]