Nov 21, 2017 01:47 AM|zxj|LINK
You can set the Layout property in the individual view also, to override default layout page setting of
_ViewStart.cshtml file can be used to specify path of layout page, which in turn will be applicable to all the views of the folder and its subfolder.
Use Layout View:
For example, the following _ViewStart.cshtml in the Views folder, sets the Layout property to "~/Views/Shared/_Layout.cshtml". So now,
_layout.cshtml would be layout view of all the views included in Views and its subfolders. So by default, all the views derived default layout page from
_ViewStart.cshtml of Views folder.
Setting Layout property in individual view:
You can also override default layout page set by _ViewStart.cshtml by setting Layout property in each individual .cshtml view. For example, the following Index view use
_myLayoutPage.cshtml even if _ViewStart.cshtml set
ViewBag.Title = "Home Page";
Layout = "~/Views/Shared/_myLayoutPage.cshtml";