How could I write code to get all the action names from a controller in asp.net MVC?
I want to automatically list all the action names from a controller.
Does an
You can start with:
Type t = typeof(YourControllerType);
MethodInfo[] mi = t.GetMethods();
foreach (MethodInfo m in mi)
{
if (m.IsPublic)
if (typeof(ActionResult).IsAssignableFrom(m.ReturnParameter.ParameterType))
methods = m.Name + Environment.NewLine + methods;
}
You'll have to work more to suit your needs.