Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Index.cshtml inconvenient name for developing in MVC4?

Basically, for every new Controller I have a Index.cshtml view which is I believe standard behavior for MVC projects. I have three gripes with this practice:

  1. If I have more than one index.cshtml opened in Visual studio, I can't tell which is which by looking at the tab.

  2. When doing a check-in to TFS I have to check folder name to know which Index.cshtml I want to check-in.

  3. In pending changes files are listed alphabetically which means that Index.cshtml will not be next to a controller file and a model file.

Do you find this bothersome or there is a better practice that I'm not aware of?

like image 400
Nezreli Avatar asked Nov 02 '22 15:11

Nezreli


1 Answers

  1. If I have more than one index.cshtml opened in Visual studio, I can't tell which is which by looking at the tab. I hover on the tab to see the path to recognize. Also, many a times I can identify by just viewing the viewbag.title or the rest of the code.

  2. When doing a check-in to TFS I have to check folder name to know which Index.cshtml I want to check-in.

  3. In pending changes files are listed alphabetically which means that Index.cshtml will not be next to a controller file and a model file. As such I use vs 2012, all the actions like view pending changes, check-in, opens all the files in the right side bar - tfs explorer window which states the folder structure above the file which is useful.

As per the convention in mvc, the controller searches for the view that should be same as a action in your controller. like Index action and Index.cshtml.

If you want to simplify your search, try giving some meaningful names to your view i.e. combination of controllers name and its action. However, this will reflect in the URL/routes which you will have to manage accordingly in the route.config settings.

like image 88
Siddharth Pandey Avatar answered Nov 08 '22 09:11

Siddharth Pandey