ASP.NET MVC – When to Separate Controllers in MVC

asp.net-mvcmvc

I'm starting with MVC and have a newbie question. What would be the logic criteria to define what a controller should encompass? For example, say a website has a 'help' section. In there, there are several options like: 'about us', 'return instructions', 'contact us', 'employment opportunities'. Each would then be accessed like 'mysite.com/help/aboutus', 'mysite.com/help/returns', 'mysite.com/help/contactus', etc.

My question is, should I have a 'help' controller that has 'about us', 'returns', 'contact us', 'employment' as actions with their respective view, or should each of those be a different controller-action-view set? What should be the line of reasoning to determine when to separate controllers?

Best Answer

That is entirely up to you.

With ASP.Net MVC3 you can choose if you want the default routing to do the work, or if you want to manually create some sexy URLs. You can create routes that look to be within the same controller but they can in fact be in many different controllers.

The criteria you should use when deciding the organization of Controllers and their method is, are these actions related in some way?

Following your example for Help. It would make sense to keep them within the same controller because they do offer "Help" in one way or another.