Get Action Method original name if its decorate with ActionName MVC attribute

I am using action filter in my MVC code i have attached action filter with below mentioned action, but this action is decorate with MVC action name attribute.

But i want action method original name(ex. ChangeOrder) but i got in action filter name as a edit. I don't want to remove ActionName attribute.

[HttpPost, ActionName("Edit")]
[FormValueRequired("btnSaveOrderStatus")]
public ActionResult ChangeOrder(int id)
{
    return View();
}

Should i get Actionmethod original name without removing ActionName attribute. please provide me way how to get original name not decorated name in mvc.


You can get the action method details corresponding to the ActionName by casting filterContext.ActionDescriptor to the ReflectedActionDescriptor in the filter. This object has MethodInfo property which gives you all details of the method.

string actionMethodName = (filterContext.ActionDescriptor as ReflectedActionDescriptor)
            .MethodInfo
            .Name;
链接地址: http://www.djcxy.com/p/23364.html

上一篇: ASP.NET MVC中的ActionName属性和UrlHelper.Action方法

下一篇: 如果使用ActionName MVC属性装饰,请获取Action Method原始名称