I’m still hoping that SubControllers make it into the MVC Framework release, but my company is doing several client projects right now using the MVC Framework. These projects are enterprise applications, not smaller websites, so subcontrollers are absolutely necessary to handle the complex logic and permissions. I’ve create an implementation of subcontrollers and added it to MvcContrib. It is pulling its weight on one client project, so I’m happy with it. It can be made better, and I’m hoping the team can take my first draft and incorporate it into the product.
Here is the revision that added SubController support to MvcContrib: http://code.google.com/p/mvccontrib/source/detail?r=508
I have included a full sample with 3 levels of nested subcontrollers and an example of a nested subcontroller owning a form and posting to itself without the parent controllers caring:
Feel free to pull down the source and let me know what you think. Even better, if you find an idea for improvement, please submit a patch. I have leveraged the IModelBinder so that subcontrollers can be passed directly into action methods, and you can hook your IoC container up so that it creates the subcontrollers and the dependencies. Decomposing complex screens infinitely increases maintainability, so this is why I consider subcontrollers a critical feature. Even if this doesn’t make it into the product, the team has done a good job making the framework extensible, so I was able to implement subcontrollers in less than 150 lines of code. I welcome your thoughts and opinions.
You can pull down the source for MvcContrib by pointing your TortoiseSVN client to http://mvccontrib.googlecode.com/svn/trunk/ Note that this is a SVN URL, not a web page URL