Before I updated from Web API 5.0.0-beta2
to 5.0.0-rc1
I could do something like this:
[RoutePrefix("api/v1/test")]
public class TestController : ApiController
{
[HttpGet]
public TestString Get()
{
return new TestString { str = "HELLO WORLD" };
}
}
so when I went to the URL /api/v1/test
it would land on the Get()
function.
After updating to Web API 5.0.0-rc1
I get a 404 when going to /api/v1/test
However, this works:
[RoutePrefix("api/v1")]
public class TestController : ApiController
{
[HttpGet("test")]
public TestString Get()
{
return new TestString { str = "HELLO WORLD" };
}
}
Can you explain why this doesn't work any longer?
** EDIT **
[HttpGet("")]
works. Then it breaks on that Get()
function.
I am not sure but I believe the Http[Get, Post, etc] type attributes have had their routing properties removed. This link hints at it:
http://blogs.microsoft.co.il/blogs/bnaya/archive/2013/08/28/asp-net-web-api-attribute-based-routing.aspx
Please see https://aspnetwebstack.codeplex.com/SourceControl/list/changesets and https://aspnetwebstack.codeplex.com/workitem/1206. Basically, the goal is to separate verb filters from attribute routing.