I am using a @section { ... } expression inside a shared template. As I don't see the shared code rendered in the section, and since I don't find hints in the internet, I am not sure if this should work at all.
Here is how I examine:
_Shared.cshtml:
...
<div class="not-in-section">
Not in section
</div>
@section Templates {
<div class="in-section">
in section
</div>
...
I see the not-in-section rendered, but not the in-section code.
In index.cshtml, I invoke like this:
...
@Html.Partial("~/Views/Shared/_Shared.cshtml")
...
@section Templates {
<script type="x-template" id="book-template">
...
So I invoke _Shared.cshtml and also refer to @section, which works fine.
Can somebody confirm this should work, or this will never work? If it should work, what should be changed?