ebb
ebb

Reputation: 9377

ASP.NET MVC - Combine controllers?

Hey there, I'm at the moment trying to make a product management application. The way it works is that you add/edit/delete a Product Category for example "Ventrilo" and then you can add/edit/delete products in that category. Now is my question do I need a controller for both the Category part and the Product part? Like:

/products/categories/add

/products/products/add/{categoryId}/

or is there a way that I somehow can combine it? Seems odd to me that I need 2 controllers for such a thing.. but maybe it's just me.

Upvotes: 0

Views: 395

Answers (1)

Mauricio Scheffer
Mauricio Scheffer

Reputation: 99730

I'd code that in separate controllers because they are operations on different entities.

However, it's not a technical limitation, you can have all actions in a single controller if you wish, you just have to override the default routes.

Upvotes: 3

Related Questions