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

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.
主站蜘蛛池模板: 台湾省| 商南县| 梁平县| 五家渠市| 石屏县| 嘉禾县| 迁西县| 会理县| 通道| 吉林省| 乌鲁木齐市| 达州市| 尤溪县| 神池县| 郴州市| 高陵县| 荔浦县| 望江县| 富蕴县| 平遥县| 山东省| 望谟县| 东山县| 绥芬河市| 施甸县| 乳源| 丰顺县| 大邑县| 密山市| 成武县| 阳春市| 丹棱县| 克拉玛依市| 桃园市| 湖口县| 车险| 栾川县| 天镇县| 南通市| 六枝特区| 黄骅市|