Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Edited Issue: {controller} variable on a controller-level attribute route [1319]

$
0
0
The following controller has '{controller}' route variable in its controller-level route. (Also applies for MVC attribute routing's controller-level route too)

1.
```
[Route("api/{controller}/{id?}")]
public class ValuesController : ApiController
{
public string GetAll()
{
return "Values.GetAll";
}
}
```
Both of the below requests succeed and return a "Values.GetAll" response
GET "/api/values"
GET "/api/customers"

2.
```
[Route("api/{controller}/{id?}")]
public class ValuesController : ApiController
{
public string GetAll()
{
return "Values.GetAll";
}
}

[Route("api/{controller}/{id?}")]
public class CustomersController : ApiController
{
public string GetAll()
{
return "Customers.GetAll";
}
}
```

Both of the below requests fail with a 404 response
GET "/api/values"
GET "/api/customers"


Ideally a user shouldn't be using '{controller}' on a controller-level route variable and also like using '{action}' on a attributed action. We should probably thrown an error upfront when
the configuration is being setup.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



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