Having a heck of a time here... (Web API 2.1, .NET 4.5.1)
I had one controller that worked perfectly:
[RoutePrefix("v1/members")]
public class MembersController : ApiController
{
[Route("{id}")]
public Member Get(string id)
{
DataGateway g = new DataGateway();
return g.GetMember(id);
}
}
Works as intended and desired like:
/v1/members/12345
But I added a new controller today and it doesn't seem to be registered or recognized at all. It doesn't get added to the Help pages and it returns a 404 Not Found when trying to access it:
[RoutePrefix("v1/test")]
public class Test : ApiController
{
[Route("{id}")]
public string Get(int id)
{
return "value";
}
}
Like I stated, the new controller doesn't show up in the Help pages and returns a 404:
/v1/test/12345
What am I doing wrong?
EDITED TO ADD:
I installed tracing and it doesn't even seem to be hitting that. The first controller works fine and shows a trace, the new Test controller doesn't show any trace info.
EDIT 2:
Updated example code to better match my actual code, which was the problem all along.
The problem was here:
[RoutePrefix("v1/test")]
public class Test : ApiController
Changed to:
[RoutePrefix("v1/test")]
public class TestController : ApiController
Seems the almighty important word "Controller" needs to be in the class name for the magic to happen.