Does anyone know how to get the route name from Attribute routing in a action filter?
For example I have a controller and attribute route like this:
[HttpGet]
[CustomActionAttribute]
[Route("~/index", Name="IndexPage")]
public async Task<ActionResult> Index()
{
//Controller logic
}
Is it possible to get route name in the CustomActionAttribute?
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
//Get the current route name here
}
You can extend RouteCollection to achieve this. You can find example code for this here