Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC Conventions

ASP.NET MVC is heavily convention-based, "convention over configuration" as they say. So, this means there's a lot of significance to what name things are given and where in the project structure they are created.

As a newcomer to ASP.NET MVC, I appreciate the power and simplicity of this approach, but I do find it a bit confusing to keep track of what conventions are in play. For example, when using UpdateModel controller method, that relies on HTML form fields having the same names as the properties of the model class. That's the obvious thing to do and most of the time it's probably what most people would do instinctively, but I can see that it would get really confusing if one were to rename something in one place and forget to rename it in the other. The linkage is somewhat 'brittle'.

So, I thought it would be useful to have a list of all the ASP.NET MVC conventions here in one place, as short statements of best practice. things like:

"HTML Form fields should have the same name as Model Properties".

Anyone have anything like that? Will you help me create a list here?

like image 490
Tim Long Avatar asked Nov 02 '25 16:11

Tim Long


1 Answers

Use the virtual path from your deployment server and enter it in the project configuration in Visual Studio. This way the visual studio development server will use the same path structure as the deployment server. This will save you countless hours of work when deploying.

like image 159
John Avatar answered Nov 04 '25 10:11

John