Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do any naming conventions exist for ASP .NET MVC 3?

As I am learning MVC 3 it has become apparent that naming is critical to getting the Dbase-Model-Controller-Views to talk together.

Is there an already existing list of naming conventions that should be used in a MVC application?

Something like:

  • Table names (plural)
  • Model names (singular of Table Name)
  • View folder must be same name as controller class (ie Contract -> derived from ContractController)
like image 237
John M Avatar asked Feb 10 '11 12:02

John M


1 Answers

The only major convention is that controller class names must end with "Controller". Any other conventions simply represent best practices and are not required for your application to work.

The table and model naming conventions you mentioned are there because they make the code "read" better (Select * From products where category = 1; Products.Insert(new Product()))

MVC automatically looks for a view that matches the name of the action method and it starts looking in a folder that has the same name as the controller. However you can easily trump that by specifying the view name in your view result (return View("MyCustomName"))

like image 112
marcind Avatar answered Nov 15 '22 06:11

marcind