Quantcast
Channel: ASP.NET MVC / Web API / Web Pages
Viewing all articles
Browse latest Browse all 7925

Created Issue: Attribute Routing fails for controllers with the same name [1249]

$
0
0
Create two controllers under different namespace

[Route("api/values1")]
public class ValuesController : ApiController
{
public HttpResponseMessage Get()
{
return new HttpResponseMessage()
{
Content = new StringContent("This is a V1 response.")
};
}
}

[Route("api/values2")]
public class ValuesController : ApiController
{
public HttpResponseMessage Get()
{
return new HttpResponseMessage()
{
Content = new StringContent("This is a V2 response.")
};
}
}

Try to hit any of the routes

Result: 404
Expected: The specific route is getting hit.


This is a simplified example for using versioning with attribute routing. Another related bug is when the Route has an inline constraint. The result is the same (the routing distinguishes between the two routes but not between the controller names).

Viewing all articles
Browse latest Browse all 7925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>