Search code examples
c#asp.net-web-apiroutesasp.net-routing

Attribute routing returns 404


but I am new to attribute routing, and I have no idea why this isn't working while everything else does so I have this

[RoutePrefix("api/statistics")]
 public class StatisticsController : ApiController

And then I have

 [HttpGet]
    [Route("categoryTagsByTotalIssues/{categoryId:int}")]
    public IHttpActionResult CategoryTagsByTotalIssues(int cateogryId)

Which when called from postman https://localhost:44363/api/statistics/categoryTagsByTotalIssues/3 returns a 404 but if I do https://localhost:44363/api/statistics/getTopFiveCategories which is something like this in code

 [HttpGet]
    [Route("getTopFiveCategories")]
    public IHttpActionResult GetTopFiveCategories()

It works, I have no idea why the other one doesn't can someone explain this to me?


Solution

  • Use this [Route("categoryTagsByTotalIssues")] And in parameter update this public IHttpActionResult CategoryTagsByTotalIssues(int categoryId)