Folders in the controller directory in ASP.NET MVC 4

I'm a little new to ASP.Net MVC 4. I am working on an application that will have many routes. With that in mind, I ran into name conflicts in my controller. Because of this, I decided that I wanted to split my controller into several controllers. In an attempt to maintain cleanliness, I feel that I need to put the controller classes in subdirectories in the controller directory. My questions:

  • Is that even an option? I can't seem to find examples with this approach.
  • How to register controllers that are in such subdirectories that when I add routes to the RouteConfig.cs file, they use the controller located in a subdirectory?

Thanks!

+7
source share
1 answer

Is this an option? Definitely. You can place the controllers wherever you want. MVC automatically scans the assembly for the controllers, and it does not matter if they are placed only under the Controllers .

If the situation becomes more complicated and you want to improve the organization, you can use the Areas concept in ASP.NET MVC - http://msdn.microsoft.com/en-us/library/ee671793(v=vs.100).aspx

+8
source

All Articles