I use attribute routing, but when I specify an empty Route attribute I get the following error:
405.0 - Method Not Allowed
However, if I add a route name in the attribute, like [Route("bar")], everything works as expected.
Why would one of these action methods work as expected, while the other one yields a 405 error?
[System.Web.Http.RoutePrefix("foo")]
public partial class MyController : ApiController
{
[System.Web.Http.HttpPost]
[System.Web.Http.Route("bar")] // I am able to POST to /foo/bar
public async Task<MyResponseModel> BarMethod([FromBody]MyArgumentsModel arguments)
{
}
[System.Web.Http.HttpPost]
[System.Web.Http.Route] // Error when I POST to /foo, "Method Not Allowed"
public async Task<MyResponseModel> FooMethod([FromBody]MyArgumentsModel arguments)
{
}
}
Any ideas what I could be missing?