I'm using attribute routing and am having this controller with two Get-methods.
When requesting any of these two Get methods I get 404 back and I don't understand why since I've followed this guide from Microsoft (especially this part).
This is how the Controller looks like:
[RoutePrefix("api/rolesubscriptions")]
public class RoleSubscriptionsController : ApiController
{
Route("roles")]
public async Task<IHttpActionResult> GetRoles()
{
}
[Route("tags")]
public async Task<IHttpActionResult> GetTags()
{
}
}
And this is my WebApiConfig.cs
file
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
Now based on this configuration I think that I would be able to do these requests
/api/rolesubscriptions/roles
and
/api/rolesubscriptions/tags
But both these requests return 404. Any help to help solve my problem is very appreciated.
EDIT 1 This is how my Application_Start() looks like
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
}
The Startup class exists but doesn't have any code that has to do with routing, only authentication.
public void Configuration(IAppBuilder app)
{
app.UseCors(CorsOptions.AllowAll);
// Authenication code omitted
}