title: Why does my .cshtml page need to define content?
body: <p>Let's say I have the following structure in my ASP.NET MVC 3 application.</p>
  
  <ul>
  <li>Items
  <ul>
  <li>Index.cshtml</li>
  </ul></li>
  <li>Categories</li>
  <li>Shared
  <ul>
  <li>_Index.cshtml</li>
  <li>_Site.cshtml </li>
  <li>Index.cshtml</li>
  </ul></li>
  </ul>
  
  <p>Both <code>Index.cshtml</code> files use <code>_Index.cshtml</code> as the layout page and <code>_Index</code> is nested within the <code>_Site</code> layout.</p>
  
  <p><code>Items/Index</code> implements the optional sections defined in <code>_Index</code>. <code>Shared/Index</code> is empty.</p>
  
  <p>The <code>Items/Index</code> view works fine. Since Categories doesn't have an Index, it uses the one in the Shared folder. This does not work.</p>
  
  <p>It throws the error</p>
  
  <blockquote>
    <p>The "RenderBody" method has not been called for layout page "~/Views/Shared/_Index.cshtml".</p>
  </blockquote>
  
  <p>If <code>_Site</code> calls <code>RenderBody</code>, and <code>_Index</code> inherits from <code>_Site</code>, doesn't the content in <code>_Index</code> satisfy the required <code>RenderBody</code> call and <code>Shared/Index.cshtml</code> can be blank?</p>
  
  <p>The reason I ask is because I have an ASP.NET MVC 1 application  that implemented this structure using Master pages and it worked fine, but converting it to MVC 3 with Razor is causing this issue.</p>
  
  <p>Here is the basic outline of what I'm describing:</p>
  
  <p>_Site.cshtml</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  // head
  &lt;body&gt;
    @RenderBody()
  &lt;/body&gt;
  </code></pre>
  
  <p>_Index.cshtml</p>
  
  <pre><code>@{
      Layout = "~/Views/Shared/_Site.cshtml";
  }
  
  &lt;div id="sub-menu"&gt;
    // Markup
  &lt;/div&gt;
  
  // More markup
  
  @RenderSection("SectionOne", required: false)
  
  @RenderSection("SectionTwo", required: false)
  </code></pre>
  
  <p>Items/Index.cshtml (Working)</p>
  
  <pre><code>@{
      Layout = "~/Views/Shared/_Index.cshtml";
  }
  
  @section SectionOne {
    // Markup
  }
  </code></pre>
  
  <p>Shared/Index.cshtml (RenderBody error)</p>
  
  <pre><code>@{
      Layout = "~/Views/Shared/_Index.cshtml";
  }
  
  // Rest of this file is empty
  </code></pre>