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

Closed Issue: Provide consistent controller inheritance behaviors between MVC and Web API attribute routing [1164]

$
0
0
Currently there is a difference in how attribute based routes are generated between Web API and MVC in case of inheritance of controllers. Should we provide a consistent experience across both of them?

In MVC:

```
[RoutePrefix("Abc")]
public class AbcController : Controller
{
[HttpGet("Index")]
public ActionResult Index()
{
return new ContentResult() { Content = "Hello!!!" };
}
}

[RoutePrefix("Def")]
public class DefController : AbcController
{
}
```
For the above case, there is only 1 route added to route collection…the route is like the following:
("routeName", "Abc/Index", new { controller = "Abc", action = "Index" }, new { httpMethod = HttpMethodConstraints[GET] }, new { TargetActionMethod = "System.Web.Mvc.ActionResult Index()" });


In Web API:
```
[RoutePrefix("Abc")]
public class AbcController : ApiController
{
[HttpGet("Index")]
public string Index()
{
return "Hello!!!";
}
}

[RoutePrefix("Def")]
public class DefController : AbcController
{
}
```

For the above case, there are 2 routes added to the route collection…they are like below:
("routeName", "Abc/Index", new { }, new { httpMethod = HttpMethodConstraints[GET] }, new { actions = [Abc.Index()] })
("routeName", "Def/Index", new { }, new { httpMethod = HttpMethodConstraints[GET] }, new { actions = [Def.Index()] });
Comments: We are tracking alignment with the Web API attribute routing implementation through https://aspnetwebstack.codeplex.com/workitem/1224.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



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