dotnet / AspNetCore.Docs

Documentation for ASP.NET Core
https://docs.microsoft.com/aspnet/core
Creative Commons Attribution 4.0 International
12.66k stars 25.28k forks source link

documentation on razor page nested layouts #11769

Open ghost opened 5 years ago

ghost commented 5 years ago

Please do create a documentation on nested layouts. If it is not yet supported. Give alternative ways.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Rick-Anderson commented 5 years ago

Thanks for contacting us. We don’t have the resources to invest in this area, so we are closing the issue. Should your request generate enough 👍 responses, we’ll reconsider.

ghost commented 4 years ago

@Rick-Anderson i did a test, but i'm not sure about the implication, but it worked. Can I add this to the documentation? If so how?

I read a section on nested layouts with Blazor but non yet in razor pages. https://docs.microsoft.com/en-us/aspnet/core/blazor/layouts?view=aspnetcore-3.1#nested-layouts

below is a working code.

Shared/_MasterLayout.cshtml

<div>i am master layout header</div>

            @RenderBody()
<div>i am master layout footer</div>

Shared/_Layout.cshtml

@{
    Layout = "_MasterLayout";
}
<div>i am layout header</div>

            @RenderBody()
<div>i am layout footer</div>

Index.cshtml

@{

    Layout = "_Layout";
}

Hello world I am Index.cshtml
Rick-Anderson commented 4 years ago

Should be the same as Blazor. I'll get this updated.