I am using .net 5 for a asp.net web site and I want to have a my themes in and orginized way.
I want to have
Theme\ThemeName\_Layout.cshtml this would be even used for say if the user went to the Home Controller
But at present no matter what i am doing its looking for it here
InvalidOperationException: The layout view ' ~/Views/Shared/FrontEnd/_Layout.cshtml' could not be located. The following locations were searched: /Views/Home/ ~/Views/Shared/FrontEnd/_Layout.cshtml
Is thee a way to have a custom view location by the way I am using razor pages cshtml.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
16 Points
125 Posts
Custom View Location in asp.net core 5
Dec 27, 2020 08:41 PM|roguenidb|LINK
I am using .net 5 for a asp.net web site and I want to have a my themes in and orginized way.
I want to have
Theme\ThemeName\_Layout.cshtml this would be even used for say if the user went to the Home Controller
But at present no matter what i am doing its looking for it here
InvalidOperationException: The layout view ' ~/Views/Shared/FrontEnd/_Layout.cshtml' could not be located. The following locations were searched: /Views/Home/ ~/Views/Shared/FrontEnd/_Layout.cshtml
Is thee a way to have a custom view location by the way I am using razor pages cshtml.
My startup.cs route data is
Contributor
2360 Points
676 Posts
Re: Custom View Location in asp.net core 5
Dec 28, 2020 07:44 AM|YihuiSun|LINK
Hi roguenidb,
Do you want to specify the Layout view? Razor views have a Layout property. Individual views specify a layout by setting this property.
If your project is a Razor Pages application, you only need to add this code to the Index page:
@{ Layout = "/Pages/Shared/Theme/ThemeName/_Layout.cshtml"; }
But according to the Startup.cs code you provided, your project looks like an MVC application,you need to add this code to the Index view:
@{ Layout = "/Views/Shared/Theme/ThemeName/_Layout.cshtml"; }
Best Regards,
YihuiSun