I just did it two weeks ago.
var q = from type in Assembly.GetExecutingAssembly().GetTypes() where type.IsClass && type.Namespace != null && type.Namespace.Contains("Controller") select type; q.ToList().ForEach(type => doWhatYouNeedToDo(type)));
if you use T4MVC then this script will return double entries. To avoid this, work with
&& !type.Name.Contains("T4MVC")
In the doWhatYouNeedToDo () method, you can convert the Type object to a DTO that suits your needs and add extra work to it.
As for your dynamic menu, you can use MvcSiteMapProvider and implement your own dynamic sitemapprovider with it, so that you are no longer attached to the xml file of the static Sitemap.
But in .NET, reflection is pretty slow, so you might want to keep the views of your controllers and method in a database.
source share