有谁知道如何从 Action 过滤器中的属性路由中获取路由名称?
例如,我有一个这样的 Controller 和属性路由:
[HttpGet]
[CustomActionAttribute]
[Route("~/index", Name="IndexPage")]
public async Task<ActionResult> Index()
{
//Controller logic
}
是否可以在 CustomActionAttribute 中获取路由名称?
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
//Get the current route name here
}
最佳答案
您可以扩展 RouteCollection 来实现这一点。您可以找到此 here 的示例代码
关于asp.net-mvc - 如何从 ASP MVC5 中的属性路由中获取路由名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26284947/