Quantcast
Channel: ASP.NET MVC / Web API / Web Pages
Viewing all articles
Browse latest Browse all 7925

Edited Unassigned: [MvcAttributeRouting]Controller-level route not hitting base action decorated with Route attribute [1273]

$
0
0
In the following controller, following is the status of requests:

GET base/about -> prints "About"
GET base/contact-> 404 Not Found (expected as there is explicit Route attribute)
GET base/hello -> prints "Contact"
GET derived/about -> prints "About"
GET derived/contact -> 404 Not Found (this is __not__ expected as Route is not inherited)

```
[Route("base/{action}")]
public class BaseController : Controller
{
[HttpGet]
public ActionResult About()
{
return Content("About");
}

[HttpGet]
[Route("base/hello")]
public virtual ActionResult Contact()
{
return Content("Contact");
}
}

[Route("derived/{action}")]
public class DerivedController : BaseController
{
}
```

Viewing all articles
Browse latest Browse all 7925

Trending Articles



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