2

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.

3
  • Why not use Edit (or ChangeOrder) everywhere? Commented Sep 12, 2016 at 4:56
  • @Div we have taking form collection from edit page. Please see question again i have update it. Commented Sep 12, 2016 at 4:59
  • @vatsal, So, you get Edit in filterContext.ActionDescriptor.ActionName? Commented Sep 12, 2016 at 5:18

1 Answer 1

2

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;
Sign up to request clarification or add additional context in comments.

1 Comment

@vatsal Glad to help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.