Reputation: 7116
I'm trying to document all the actions in my web app, and one of the things I want do is to provide a sample URL for an action.
Is there a way to list all the actions in a website along with their routes, or maybe a way to find the route from a MethodInfo?
I'm thinking I might have to write a custom attribute for each action to specify dummy values to use for actions with parameters.
Upvotes: 0
Views: 493
Reputation: 1038930
You could easily get all the actions using reflection:
var actions =
from controller in Assembly.GetExecutingAssembly().GetTypes()
where typeof(Controller).IsAssignableFrom(controller)
from action in controller.GetMethods()
where typeof(ActionResult).IsAssignableFrom(action.ReturnType)
select new { Controller = controller, Action = action };
Adapt to include the assemblies you are interested in.
Upvotes: 1