We are currently using the default folder structure for our MVC app, and were wondering if it is possible to instead put a Controller and its related views into the same folder.
For example, a subset of our current structure is:
Model folder
OrderViewModel.cs
Views folder
OrderView.aspx
OrderGrid.ascx
OrderHeader.ascx
Controllers folder
OrderController.cs
Desired:
Order folder
OrderController.cs
OrderGrid.ascx
OrderHeader.ascx
OrderViewModel.cs
OrderView.aspx
We have hundreds of actions/views, and they’re currently grouped into too few controllers. This is partly because it becomes a pain to navigate around the project when flipping back and forth between a view and its related classes. The above solution would allow a developer focusing on one controller action to have all of them easily accessible.
I guess Areas could help with this too, but we’d have to make ~100 areas (one per set of closely related screens) to make this useful from my team’s POV.
The default controller factory uses reflection to find all classes that derive from
Controller, so no matter in which folder you put them, as long as they are public and derive fromControllerit will work. But IMHO mixing views and controllers into the same folder is not a good idea. If it is a matter of organizing your controllers why not create subfolders in theControllersfolder?