I’m trying to write a unit test that will loop through all action methods on my controller classes looking for action methods that don’t have some security-related attribute on them (e.g. [Authorize]).
How does the ASP.NET routing engine determine which methods are action methods? Obviously the action methods have to be public, but methods like ToString() are not action methods, so there is some logic to this.
I stopped being lazy and I found the answer, most of which was in System.Web.Mvc.ActionMethodSelector.PopulateLookupTables() (thanks Reflector!)
I was surprised to see all of the public methods on my base controller classes that were exposed with no security on them!