Getting All Controllers and Actions names in C#

前端 未结 9 1622
耶瑟儿~
耶瑟儿~ 2020-11-27 10:56

Is it possible to list the names of all controllers and their actions programmatically?

I want to implement database driven security for each controller and action.

9条回答
  •  有刺的猬
    2020-11-27 11:33

    Use Reflection, enumerate all types inside the assembly and filter classes inherited from System.Web.MVC.Controller, than list public methods of this types as actions

提交回复
热议问题