config.Routes.MapHttpRoute( name: "MyRoute", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } );
config.Routes.MapHttpRoute( name: "GetRoute", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional }, constraints: new { httpMethod = new HttpMethodConstraint(HttpMethod.Get) } );In this example, the "constraints" parameter is used to only match the route for HTTP GET requests. Any other HTTP verb will be rejected. The System MapHttpRoute class is part of the System.Web.Http package library, which is a set of classes and tools for building HTTP services using ASP.NET Web API.