Let's say that I have a controller with two actions, RouteOne (GET) and RouteTwo (POST). I also have the default route registered, so if the controller is HomeController, I should be able to get to the controller by going to this URL in a browser:

GET Home/RouteOne

The question: Given an URL and an HTTP verb, how can I get a reference to the MethodInfo of the controller action I'm trying to run? This includes actions that use query string parameters.

Example: this action inside of the HomeController:

[HttpGet] public ActionResult AnAction(string param1, int param2) {}

should be resolved with an HTTP verb of GET and a URL of:

Home/AnAction?param1=asdf&param2=1234

The ultimate goal is to determine whether or not someone has access to a given URL, using the AuthorizeAttribute to provide role information. If there's another way to determine this, I'm all ears.

Related posts

Recent Viewed