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