title: How do you get the current MVC Area name in a .cshtml file in ASP.NET Core
body: <p>I can get the current controller name and action name in a <code>_Layout.cshtml</code>  by doing the following</p>
  
  <pre><code>var controller = ViewContext.RouteData.Values["controller"].ToString();
  var action = ViewContext.RouteData.Values["action"].ToString();
  </code></pre>
  
  <p>However when I try get the area</p>
  
  <pre><code>var area = ViewContext.RouteData.Values["area"].ToString();
  </code></pre>
  
  <p>it doesn't work as only 2 keys exist in that object("controller" and "action")</p>
  
  <p>I examined the <code>ViewContext.RouteData</code> object and cannot get a value for the current Area name.</p>
  
  <p>The <a href="https://stackoverflow.com/questions/2723689/asp-net-mvc-get-current-area-name-in-view-or-controller">previous answers</a> for the previous version of <code>ASP.net</code> don't work for me.</p>