From a custom HtmlHelper extension, I would like to get the MethodInfo for the action.
I know I can get the Type of the controller, and the string name of the action from:
public static void MyHelper(this HtmlHelper helper)
{
var controller = helper.ViewContext.Controller;
var actionName = ViewContext.Controller.ValueProvider.GetValue("action").RawValue;
}
But I really want the MethodInfo because I want to pull a custom Attribute off the action method. I can't just call reflection .GetMethod(actionName); because there is usually more than 1 with the same name (two actions with the same name, one for the http GET and one for the POST).
At this point I am thinking I might have to manually get all methods with the action name, and run through all the info in ViewContext.Controller.ValueProvider to see what method has parameters that match the values in the provider, but I am hoping the MethodInfo is already available somewhere...