title: Get Areas associated with an MVC project
body: <p>Is there a way I can get the names of the areas in an MVC project?</p>
  
  <p>Here's a few ways I can think of:</p>
  
  <p>a) If I had the source, I could browse through the project folder structure and enumerate the folders under the Areas folder. But that wouldn't guarantee all the folders represent areas unless I also enumerated the Controllers and Views folder under each of the sub-folders. This approach, as you can tell, sucks.</p>
  
  <p>b) From the binary, I could enumerate all namespaces that match the criteria <code>RootNamespaceOfProject.Areas.*</code>.</p>
  
  <p>Or, I am sure there's a more elegant way. There must be some dictionary in the ASP.NET MVC framework that keeps a record of all the areas.</p>
  
  <p>Secondly, is there also a programmatic construct in the MVC framework that represents an area? I can't seem to find one. There are only four constructs that are <em>related</em> to areas:</p>
  
  <pre><code> 1. AreaRegistration
   2. AreaRegistrationContext
   3. IRouteWithArea
   4. AreaHelpers (an internal class)
  </code></pre>
  
  <p>If there were one, would it be possible, say, to enumerate all the controllers within that area?</p>
  
  <p><strong>Edited</strong></p>
  
  <p>I just noticed that there's this file called <code>MVC-AreaRegistrationTypeCache.xml</code> in the folder \Windows\Microsoft.NET\Framework\v4.x.x\Temporary ASP.NET Files\root\RandomlyGeneratedHash1\RandomlyGeneratedHash2\UserCache.</p>
  
  <p>This folder has two files:</p>
  
  <p>a) <strong>MVC-AreaRegistrationTypeCache.xml</strong>: This file has the list of all the areas in all the assemblies on the machine that have areas.</p>
  
  <p>b) <strong>MVC-ControllerTypeCache.xml</strong>: This file lists the controllers within the areas of the assemblies.</p>
  
  <p>Now, the only thing to find out is if there's some programmatic way to have the MVC framework read these files and tell me if a certain area exists in a binary.</p>
  
  <p>I am thinking that the <code>AreaRegistration</code> class might be the one. Exploring it further...</p>