1

The project I'm starting to work at will have several dozens of controllers, so it would be nice to structure them into logical directories and respective namespaces, like "Controllers/Admin/", "Controllers/Warehouse/Supplies/", etc.

Does ASP.NET MVC support nested controller directories and namespacing? How do I manage routes to those controllers?

mocco
  • 3
  • 1
  • 3

1 Answers1

2

You can put the controllers anywhere; routes do not depend on where a controller is stored. It will be able to find any class that implements IController within your application.

I usually keep my controllers in a separate project, f.ex a MyProject.Frontend project, alongisde a MyProject.Frontend.Application project which is the actual entrypoint web project with the views etc.

Fredrik Kalseth
  • 13,934
  • 4
  • 25
  • 17
  • Hi Fredrik, does this apply to the views folder too? Or, can you also arrange the views folder into subfolders to neaten things up a bit? – Jacques Jul 12 '12 at 13:09
  • @Jacques: This is answered here on SO: http://stackoverflow.com/questions/4515996/reorganizing-an-asp-net-mvc-folder-structure. Basically you need to use areas. – Sudhanshu Mishra Jul 18 '13 at 10:21