官术网_书友最值得收藏!

View files and their location

View files are saved with the extension .cshtml, which implies that these are files containing both HTML markup and C# code.

They are located within subfolders under the Views folder. By convention, each subfolder matches a single controller. For example, if the project has a controller named HomeController, then the views of this controller will reside inside the Views/Home folder.

The view's filename correlates to the controller action for which it generates the output. We saw in the previous section that the controller action ended with this line:

return View();

This line tells ASP.NET Core MVC to look for a file named <current action name>.cshtml under Views/<controller name>. For example, if the controller is named HomeController and the action is named Index, then the view file will be Views/Home/Index.cshtml.

The view file lookup process can be modified to look for other view names, search in different directories, and more. These capabilities are not needed for most SPA applications, and therefore, are not within the context of this book.
主站蜘蛛池模板: 登封市| 衡东县| 务川| 如皋市| 西华县| 邵东县| 朝阳市| 涿州市| 东乌珠穆沁旗| 黄冈市| 兴宁市| 沈阳市| 临高县| 新津县| 南溪县| 寿宁县| 石狮市| 达日县| 岑巩县| 肇庆市| 土默特左旗| 和平区| 梓潼县| 木兰县| 托克托县| 汶川县| 陈巴尔虎旗| 新建县| 色达县| 越西县| 教育| 文昌市| 瓮安县| 德格县| 尉犁县| 辽源市| 博爱县| 蓬安县| 禄丰县| 阿巴嘎旗| 如东县|