2021年3月17日星期三

Is it possible to have multiple layout pages in a C# razor application?

Previously I have created C# applications using MVC and it is possible to specify the layout view to use on the view in it's file. Such that the view file contains:

@{      Layout = "~/Views/Shared/_Layout.cshtml";  }    /*Rest of file*/  

Recently I have started creating applications using razor pages. So far I only have a single layout page. However, I would like to use a different layout page for a subset of pages, and I can only see how to specify a single layout page for all pages within the Pages folder. As the layout is declared in the _ViewStart.cshtml file. Where the contents of this file is simply:

@{      Layout = "_Layout";  }  

Is there a way of using one layout file for some pages, and then a different layout files for other pages?

https://stackoverflow.com/questions/66677591/is-it-possible-to-have-multiple-layout-pages-in-a-c-sharp-razor-application March 18, 2021 at 12:48AM

没有评论:

发表评论