Having been a part of many large enterprise ASP.NET MVC application implementations using test driven development I learned early on that separating your controller classes into a their own project significantly reduces the noise in your web project. It wasn’t until a recent talk I gave to user group in my region that I realized that this isn’t a widely adopted practice. For large applications with a lot of developers and a complex architecture I highly recommend it.
Putting your controllers in a separate assembly is very straight forward. First create a controllers project in your solution and then you just need to update your route registrations to tell them where to look for the controllers.
In order to tell ASP.NET MVC where to look for your controllers when registering your routes you use the ‘namespaces’ parameter of the MapRoute method as illustrated above.
I know that the concept of putting controllers in a separate assembly is a bit controversial and everyone seems to have a strong opinion either for or against, so let me know what side of the fence you fall on.
Keith Burnell is a Microsoft web MVP and Senior Software Engineer with Skyline Technologies and president of the Fox Valley .Net User Group. Keith has been developing software for over 10 years specializing in large scale ASP.NET and ASP.NET MVC web site development and architecture
The opinions expressed herein are my own personal opinions and do not represent
my employer's view in any way.