title: How to tell ASP.NET MVC to include cshtml in every view in folder
body: <p>Here is my problem:</p>
  
  <p>For one controller <code>ProjectsController.cs</code> I want that every view would include some razor code.</p>
  
  <p>For now I have something like this:</p>
  
  <p>In <code>Views/Shared/_Layout.cshtml</code> I render optional section <code>header</code>:</p>
  
  <pre><code>     ...&lt;/div&gt;
  &lt;/div&gt;
  @RenderSection("header", false)
  &lt;div class="container body-content"&gt;
      @RenderBody()
      &lt;hr /&gt;
      &lt;footer&gt;...
  </code></pre>
  
  <p>Then in my <code>View/Projects</code> folder I have created partial view <code>_ProjectsPartial.cshtml</code></p>
  
  <p><a href="https://i.stack.imgur.com/N5KlC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N5KlC.png" alt="enter image description here"></a> </p>
  
  <p>And I include in every view in Projects folder header section, so <code>Views/Projects/Index.cshtml</code> and <code>Views/Projects/Console.cshtml</code> have this included:</p>
  
  <pre><code>@section header
  {
      @Html.Partial("_ProjectsPartial")
  }
  </code></pre>
  
  <p>It works, as it should but I have a feeling this is not the way to do it, and I need to include this <code>@section header</code> in every view under <code>Views/Projects</code> which is not ideal, as I want to add many views in the future in this folder.</p>
  
  <p><strong>So my question is, what is the best way to do it?</strong></p>
  
  <p>I know I could use other layout for all these views adding and using <code>Views/Projects/_ViewStart.cshtml</code> but then I would need to duplicate main layout code as I don't know how to merge one layout into other.</p>