How to get route name from attribute routing in ASP MVC5

Does anyone know how to get route name from attribute routing in action filter?

For example, I have a controller and attribute route as follows:

[HttpGet] [CustomActionAttribute] [Route("~/index", Name="IndexPage")] public async Task<ActionResult> Index() { //Controller logic } 

Can I get the name of the route in the CustomActionAttribute attribute?

 public override void OnActionExecuting(ActionExecutingContext filterContext) { //Get the current route name here } 
+5
source share
1 answer

You can extend the RouteCollection to achieve this. You can find sample code for here

+1
source

Source: https://habr.com/ru/post/1204352/


All Articles