title: The file "~/Views/Position/Edit.cshtml" cannot be requested directly because it calls the "RenderSection" method
body: <p>I am trying to separate all the things that I could reuse in sections, so it would be easier for me to maintain.</p>
  
  <p>However I got this exception:
  The file "~/Views/Position/Edit.cshtml" cannot be requested directly because it calls the "RenderSection" method</p>
  
  <p>I created a file called sections.cshtml with the following content:</p>
  
  <pre><code>@section scripts{
      &lt;script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"&gt;&lt;/script&gt;
  }
  </code></pre>
  
  <p>And in the _layout.cshtml file I changed it to:</p>
  
  <pre><code>&lt;head&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;title&gt;@ViewBag.Title&lt;/title&gt;
      &lt;link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" /&gt;
      @RenderSection("scripts", required:false)
      @*&lt;script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"&gt;&lt;/script&gt;*@
  &lt;/head&gt;
  </code></pre>
  
  <p>When I go to the view in the browser and check the source code it shows only:</p>
  
  <pre><code>&lt;head&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;title&gt;Edit&lt;/title&gt;
      &lt;link href="/Content/Site.css" rel="stylesheet" type="text/css" /&gt;
  &lt;/head&gt;
  </code></pre>