ASP.NET MVC Programmatically Get a List of Controllers

前端 未结 4 2056
轻奢々
轻奢々 2020-11-30 03:57

In ASP.NET MVC is there a way to enumerate the controllers through code and get their name?

example:

AccountController
HomeController
PersonControlle         


        
4条回答
  •  遥遥无期
    2020-11-30 04:21

    You can reflect through your assembly and find all classes which inherit from type System.Web.MVC.Controller. Here's some sample code that shows how you could do that:

    http://mvcsitemap.codeplex.com/WorkItem/View.aspx?WorkItemId=1567

提交回复
热议问题