title: How to get a session value in layout file in ASP.NET 5 MVC6
body: <p>In ASP.NET 5 MVC 6 Beta 8 I need to read a session variable in in my <code>_Layout.cshtml</code> or alternatively get a reference to the current  HttpContext.</p>
  
  <p>Take note: In ASP.NET 5 referencing the Session object has changed significantly from ASP.net 4 as detailed in <a href="https://stackoverflow.com/questions/33210026/context-keyword-doesnt-get-recognized-in-asp-net-5-mvc-controller-for-use-with">this</a> question</p>
  
  <p>The <code>Context</code> object has also been renamed to <code>HttpContext</code> between Beta7 and Beta8.</p>
  
  <p>In My current controller I currently save the session variable like this</p>
  
  <pre><code>public IActionResult Index()
  {
      HttpContext.Session.SetInt32("Template", (id));
  }
  </code></pre>
  
  <p>In my _Layout.cshtml I need to read the above session variable.
  I need to reference the current HttpContext somehow e.g</p>
  
  <pre><code>HttpContext.Current.Session.GetInt32("Template");
  </code></pre>
  
  <p>but I don't know how to the get the current HttpContext in a cshtml file. </p>