views:

309

answers:

3

I have a fairly large ASP MVC application. Instead of having many controllers all in the controller directory I would rather create some hierarchy. So I might have something like

~\Controllers\Security\
~\Controllers\Maintenance\
~\Controllers\Reports\

I would also like to be able to do similar with Views

~\Views\Security\Users\
~\Views\Security\Roles\
~\Views\Maintenance\Customer\
~\Views\Maintenance\Product\

Is this easily done?

+1  A: 

I would think you'd need to write your own RouteHandler, which shouldn't be too tough.

A quick google search turned up: This blog post detailing it

DaRKoN_
+3  A: 

I think you're looking for something like what the "master" says in this post:

http://haacked.com/archive/0001/01/01/areas-in-aspnetmvc.aspx

Basically you have to create a ViewEngine to specify where to look for the views. It's a fairly simple code, just don't forget to register it in the global.asax! As for the controller part you'll have to register new routes also in the global.asax.

antonioh
+2  A: 

The concept you're searching for is called "areas", as outlined by Phil Haack here: http://haacked.com/archive/2008/11/04/areas-in-aspnetmvc.aspx

Portman
Man, I am NEVER fast enough!!
Portman