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

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.
主站蜘蛛池模板: 顺平县| 泰来县| 永春县| 垣曲县| 瓮安县| 曲沃县| 青阳县| 丹寨县| 英吉沙县| 江孜县| 乐亭县| 中阳县| 容城县| 林甸县| 太和县| 东平县| 韶关市| 南阳市| 隆昌县| 筠连县| 乐陵市| 江西省| 寻乌县| 阿拉善左旗| 巫山县| 武安市| 织金县| 遂川县| 教育| 巩留县| 简阳市| 丰县| 阳高县| 重庆市| 菏泽市| 博野县| 全州县| 朝阳区| 瑞丽市| 瓦房店市| 洞头县|