Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am wondering if its possible to use the same parameter name in URL routes using ASP.NET WebAPI.

For example

    [HttpGet]
    [Route("{userid}")]

    [HttpGet]
    [Route("{userid}/customers")]

    [HttpGet]
    [Route("{userid}/orders")]

When i have the routes set up like this i get an error saying there are multiple actions for this request. However

    [HttpGet]
    [Route("{userid}")]

    [HttpGet]
    [Route("{userid2}/customers")]

    [HttpGet]
    [Route("{userid3}/orders")]

works.

Any thoughts?

share|improve this question
    
Please try by changing the route from- [Route("{userid}/orders")] to [HttpGet] [Route("orders/{userid}")] –  WonderHeart 16 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.