title: MVC5 get area name when using attribute routing
body: <p>I have an old MVC3 site where I was able to get the area of a route by using the following code:</p>
  
  <pre><code>object oArea;
  
  RouteData.DataTokens.TryGetValue("area", out aArea);
  </code></pre>
  
  <p>I am creating a new MVC5 application and have started to use attribute based routing as follows:</p>
  
  <pre><code>[RouteArea("Area")]
  [RoutePrefix("Test")]
  public TestController
  {
      public ActionResult Index()
      {
           return View("Index");
      }
  }
  </code></pre>
  
  <p>Unfortunately, it appears that when you use attribute based routing then the RouteData.DataTokens collection is empty.  The area information appears buried  under the RouteData in "MS_DirectRouteMatches", so you could get the data as follows:</p>
  
  <pre><code>RouteData.Values["MS_DirectRouteMatches"])[0].DataTokens.TryGetValue("area", out oArea);
  </code></pre>
  
  <p>However, I was wondering if there is an easier, safer or better way to get the area data in MVC5.  The area name is actually the sub-tool name within a larger application, which is used for some logic in the base controller initialization.</p>