如何在 OnActionExecuting 中获取控制器和动作名称? [英] How to get controller and action name in OnActionExecuting?
本文介绍了如何在 OnActionExecuting 中获取控制器和动作名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在 OnActionExecuting 中找出当前正在执行的控制器/动作?
Is it possible to figure out the currently executing controller/action in OnActionExecuting?
推荐答案
你可以试试 ActionDescriptor
的 ActionExecutingContext
如下:
You could try the ActionDescriptor
of the ActionExecutingContext
as follows:
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
string actionName = filterContext.ActionDescriptor.ActionName;
string controllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName
.....
base.OnActionExecuting(filterContext);
}
这篇关于如何在 OnActionExecuting 中获取控制器和动作名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文