I\'m relatively new to the MVC framework but I do have a functioning Web Project with an API controller that utilizes AttributeRouting (NuGet package) - however, I\'m starti
In nuGet package manager install to your project Web API Web Host package
add this class to folder app_start-> WebApiConfig.cs(if it doesn't exits - create):
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes(); // pay attention to this method
//here you can map any mvc route
//config.Routes.MapHttpRoute(
// name: "DefaultApi",
// routeTemplate: "api/{controller}/{id}",
// defaults: new { id = RouteParameter.Optional }
//);
config.EnableSystemDiagnosticsTracing();
}
}
after Try change your Global.asax configuration to:
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
GlobalConfiguration.Configure(WebApiConfig.Register);
}
}
P.S.
look through this article, very useful http://www.asp.net/web-api/overview/web-api-routing-and-actions/attribute-routing-in-web-api-2
cheers