I'm trying to programmatically create a route in ASP.NET Web Api that s
config.Routes.MapHttpRoute(
name: "test",
routeTemplate: "api/foo",
defaults: new
{
controller = "Foo",
action = "Test"
},
constraints: new
{
httpMethod = new HttpMethodConstraint(HttpMethod.Get)
});
However, if I try to invoke the method with a GET I get the following response.
{
Message: "The requested resource does not support http method 'GET'."
}
If I switch the constraint to POST and invoke with a POST, all works well (and the action shows on the help page).
Any ideas what I'm doing wrong?