title: asp.net mvs Section within a Partial/Section?
body: <p>I have some simple <code>&lt;header&gt;</code> stuff in the file Shared/_Header.cshtml.</p>
  
  <p>My Shared/_Layout.cshtml inserts that code by calling</p>
  
  <pre><code>@Html.Partial("_Header")
  </code></pre>
  
  <p>This worked fine so far.</p>
  
  <p>Now I have some views that, in addition to the normal output via the <code>@RenderBody()</code>, should also add some icons in a specific place in the header.</p>
  
  <p>I use<code>@RenderSection()</code>in a couple of my views, to create a sidebar, etc.</p>
  
  <p>Now my idea was to create a section within my view (e.g Home/Details.cshtml) and add a <code>RenderSection</code> call to the _Header. The Layout would call the Header, and header in turn would see if the section existed and call it.</p>
  
  <p>However that doesn't seem to work. I get the following error/exception:</p>
  
  <pre><code>The file "~/Views/Shared/_Header.cshtml" cannot be requested directly because it calls the "RenderSection" method.
  </code></pre>
  
  <p>Where lies my error? I know I can "nest" a partial call inside a section just fine. This code works just fine to tell the layout what file to use for a sidebar:</p>
  
  <pre><code>@section Sidebar{
      @Html.Partial("_SidebarDetails")
  }
  </code></pre>
  
  <p>Does it not work the other way round?</p>
  
  <p>I need way to define a block of HTML inside a view that is then put into a predefined place inside of a partial that is called by the layout. </p>
  
  <p>Please help me understand how to do this.</p>