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

Created Unassigned: Error when a controller derives from another having a default route with name [1243]

$
0
0
For the following controller setup, when I am launching the application, I am seeing an error related to same route name ("EmployeesApi") being added to the collection.

__Reason__: We currently are inheriting Route attributes because of which this is a problem. A route with name "EmployeesApi" gets added for EmployeesController and when generating routes for ManagerController, since we are inheriting from base controller, we are trying to add "EmployeesApi" again to the collection which is causing this error.

__Attached__ a katana selfhost repro.

__Expected__: do not inherit from base controller and let subclasses explicitly specify the attribute.

```
[Route("api/employees/{id?}", Name="EmployeesApi")]
public class EmployeesController : ApiController
{
public IEnumerable<string> GetAll()
{
return new string[] { "value1", "value2" };
}

public string GetSingle(int id)
{
return "value:" + this.GetType().Name;
}

public void Post([FromBody]string value)
{
}

public void Put(int id, [FromBody]string value)
{
}

public void Delete(int id)
{
}
}

[Route("api/managers/{id?}", Name = "ManagersApi")]
public class ManagersController : EmployeesController
{
}
```

Viewing all articles
Browse latest Browse all 7215

Trending Articles



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