Is Index.cshtml not enough name for development in MVC4?

Basically, for each new controller, I have an Index.cshtml view, which I consider to be standard behavior for MVC projects. I have three fights with this practice:

  • If I have more than one index.cshtml open in Visual Studio, I can’t say what it is, looking at the tab.

  • When registering with TFS, I need to check the folder name to find out which Index.cshtml I want to register.

  • Pending changes, the files are listed in alphabetical order, which means that Index.cshtml will not be next to the controller file and the model file.

Do you find it annoying or is there a best practice that I don't know about?

+4
source share
1 answer
  • If more than one index.cshtml is open in Visual Studio, I cannot determine what it is by looking at the tab. I have a cursor on the tab to see the path to recognition. Also, many times I can determine just by looking at viewbag.title or the rest of the code.

  • When registering in TFS, I need to check the folder name to find out which Index.cshtml I want to check.

  • Pending changes, the files are listed in alphabetical order, which means that Index.cshtml will not be next to the controller file and the model file. As such, I use vs 2012, all actions, such as viewing pending changes, registering, open all the files in the right pane - the tfs explorer window, which indicates the folder structure above the useful file.

By convention in mvc, the controller is looking for a view that should be the same as the action in your controller. e.g. Index action and Index.cshtml .

If you want to simplify your search, try specifying some meaningful names for your view, that is, a combination of the name of the controllers and their actions. However, this will be reflected in the URLs / routes that you will need to manage accordingly in the route.config settings.

+2
source

Source: https://habr.com/ru/post/1500522/


All Articles