Attribute routing can get a bit verbose when you are dealing with simple resource oriented ApiControllers. The proposal is to add a DefaultRouteAttribute that specifies the default route for all actions on the ApiController. For example:
```
// All actions use this default route
[DefaultRoute("api/values/{"id?")]
public class ValuesController : ApiController
{
public IEnumerable<String> GetValues() { ... }
public string GetValue(int id) { ... }
public void PostValue(string value) { ... }
public void PutValue(int id, string value) { ... }
public void DeleteValue(int id) { ... }
}
```
The default route can be overridden by explicitly specifying a route on an action, like this:
```
[DefaultRoute("api/values")]
public class ValuesController : ApiController
{
// Uses default route
public IEnumerable<String> GetValues() { ... }
// Overrides default route
[Route("{id}")]
public string GetValue(int id) { ... }
// Uses default route
public void PostValue(string value) { ... }
// Overrides default route
[Route("{id}")]
public void PutValue(int id, string value) { ... }
// Overrides default route
[Route("{id}")]
public void DeleteValue(int id) { ... }
}
```
A route prefix applies to default routes just like it would to any other route.
```
// All actions use this default route
[DefaultRoute("api/values/{"id?")]
public class ValuesController : ApiController
{
public IEnumerable<String> GetValues() { ... }
public string GetValue(int id) { ... }
public void PostValue(string value) { ... }
public void PutValue(int id, string value) { ... }
public void DeleteValue(int id) { ... }
}
```
The default route can be overridden by explicitly specifying a route on an action, like this:
```
[DefaultRoute("api/values")]
public class ValuesController : ApiController
{
// Uses default route
public IEnumerable<String> GetValues() { ... }
// Overrides default route
[Route("{id}")]
public string GetValue(int id) { ... }
// Uses default route
public void PostValue(string value) { ... }
// Overrides default route
[Route("{id}")]
public void PutValue(int id, string value) { ... }
// Overrides default route
[Route("{id}")]
public void DeleteValue(int id) { ... }
}
```
A route prefix applies to default routes just like it would to any other route.