文章目录
1._ViewStart.cshtml的使用
step1: 在Views文件夹下面创建_ViewStart.cshtml文件
step2: 删掉视图文件中的Layout设置行

step3: 最终显示效果:


2.更换Layout文件
step1: 新建_Layout2.cshtml 文件
step2: 在_ViewStart.cshtm 文件中指向新的Layout2文件:
step3: 在_Layout2.cshtml 文件中新添加一行h2,方便区分第一个layout文件:
step4: 最终显示效果:
3._ViewImports.cshtml文件的使用
ViewImports 文件的使用,就是提前导入环境变量,最终在视图函数里面可以更加专注于具体类、mode的使用,也可以简化下代码的冗余。
step1: 创建_ViewImports.cshtml文件

step2: 在_ViewImports.cshtml文件中导入视图文件需要的环境变量
step3: 精简视图文件中model的引用代码
