weblar83
weblar83

Reputation: 731

ASP.NET MVC Controller - Singular or Plural and Does It Matter

I know its a question which has been asked hundreds of times before but I'm stressing over the naming scheme I adopt for Controllers in my ASP.Net MVC application.

Say, for example, I have a model called User of which I have the singular ability to view, update and delete. Likewise, I also have a collection of Users which I can search upon giving many results.

As the routing is of the form of {controller}/{action}/{parameter} then my 'English' head thinks that a URL of:

http://localhost/users/view/123 is not correct as the URL relates to a single product whereas:

http://localhost/user/view/123 is correct, as the user is viewing a single product

And likewise, with Product and Products:

http://localhost/product/edit/P123456

http://localhost/products/?searchQuery

This seems to make more sense (well, to me anyway) and thus means that I have to implement two Controllers for each Model but at least this means I know that the singular controller deals with a single entity whereas the plural version deals with multiple entities:

UserController -> Add, Edit, View, Delete
UsersController -> Find, Delete

I guess the only fly in the ointment is when I come across an entity which is the same singularly as plural but within the scope of my project, this could be quite a rare thing.

I'm sorry if this is mindless babble however I'd appreciate some input from users who've gone through this before.

Upvotes: 1

Views: 1307

Answers (1)

BrilBroeder
BrilBroeder

Reputation: 1579

It does not matter. Users are normally not navigation through your site by typing urls, but by clicking links, buttons, menu's, ....

Upvotes: 1

Related Questions