I spent some time trying to remove layout (defined in _ViewStart) using:
@Layout = ""
and
@Layout = null
Why does it only work using block?
@{
Layout = "";
}
In my vision, both ways should work.
@Layout
is a code nugget.
It prints the value of the Layout
property.
The Razor parser stops at the space after the word Layout
, so the = null
is parsed as literal markup.
You want to execute a statement, not print a value, so you need to use a code block (@{ ... }
).
For more information, see my blog post.
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