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

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.
主站蜘蛛池模板: 宁化县| 莱阳市| 古浪县| 泗水县| 沾化县| 图木舒克市| 广宗县| 得荣县| 潜江市| 基隆市| 濉溪县| 江津市| 清原| 泗水县| 万宁市| 青海省| 沛县| 汶上县| 寿光市| 宁都县| 汾阳市| 东平县| 文登市| 江源县| 杭州市| 泰顺县| 旺苍县| 梁河县| 吉木乃县| 马边| 马公市| 手游| 满洲里市| 五台县| 且末县| 安溪县| 张北县| 临沧市| 广汉市| 明光市| 余庆县|