__Note__: This behavior exists even in MVC attribute routing too. I haven't filed a new bug for it, but would like to use this bug.
In the following scenario, the Get() action on ReproController, which is decorated with an attribute route is _not_ being added to the route collection.
On the other hand, the Get() action on the WorkingConroller is added to the route collection as expected.
Expected: Get() action on ReproController should be part of route collection
Actual: Not added to route collection.
```
public class ReproController : ApiController
{
//NOTE: NOT added to route collection
[HttpGet(RouteName="GetAllValues")]
public string Get()
{
return "Repro.GetAllValues";
}
}
public class WorkingController : ApiController
{
//NOTE: ADDED to route collection. Notice the empty route template
[HttpGet("", RouteName = "GetAllValues2")]
public string Get()
{
return "Working.GetAllValues2";
}
}
```
Comments: Ideally we would be able to make something like the following work so that we don't have to overburden ApiControllers with too many attributes: [DefaultRoute("api/values/{id?}")] public class ValuesController : ApiController { // GET api/values public IEnumerable<string> Get() { return new string[] { "value1", "value2" }; } // GET api/values/5 public string Get(int id) { return "value"; } // POST api/values public void Post([FromBody]string value) { } // PUT api/values/5 public void Put(int id, [FromBody]string value) { } // DELETE api/values/5 public void Delete(int id) { } } If an action has an explicit route attribute, it would override the default route specified on the controller.
In the following scenario, the Get() action on ReproController, which is decorated with an attribute route is _not_ being added to the route collection.
On the other hand, the Get() action on the WorkingConroller is added to the route collection as expected.
Expected: Get() action on ReproController should be part of route collection
Actual: Not added to route collection.
```
public class ReproController : ApiController
{
//NOTE: NOT added to route collection
[HttpGet(RouteName="GetAllValues")]
public string Get()
{
return "Repro.GetAllValues";
}
}
public class WorkingController : ApiController
{
//NOTE: ADDED to route collection. Notice the empty route template
[HttpGet("", RouteName = "GetAllValues2")]
public string Get()
{
return "Working.GetAllValues2";
}
}
```
Comments: Ideally we would be able to make something like the following work so that we don't have to overburden ApiControllers with too many attributes: [DefaultRoute("api/values/{id?}")] public class ValuesController : ApiController { // GET api/values public IEnumerable<string> Get() { return new string[] { "value1", "value2" }; } // GET api/values/5 public string Get(int id) { return "value"; } // POST api/values public void Post([FromBody]string value) { } // PUT api/values/5 public void Put(int id, [FromBody]string value) { } // DELETE api/values/5 public void Delete(int id) { } } If an action has an explicit route attribute, it would override the default route specified on the controller.