Is there a reason why you would want to set the Layout property to null in a _Layout.cshtml?
For example, like this, before rendering the body view?
...
<section id="content">
@{ Layout = null; }
@RenderBody()
</section>
...
It seems pretty nonsensical to me, and removing the line setting Layout doesn't change the way page loads work observationally.
Is there any reason why you would want to set the Layout property in _Layout.cshtml?
Layout pages can have a layout too. In nested layouts , you intentionally use Layout property to define super layout of layout page . By default it is null in your layout page if you do not specify any. When you make @{Layout=null}
you are explicitly saying that this your final layout so it is not nested in any super layout.
If you want to create a partial view that will not inherit any layout from _Layout than you will use @{ Layout = null; } in the begining of your partial view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With