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).
[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).