Search code examples
asp.netasp.net-mvc-3areas

ASP.NET MVC3 List all areas


I have an ASP.NET MVC3 application in which I am creating multiple areas, is there a way I can find out programmatically the number of areas that are present and their names. What I want to do it create some partial pages in the different areas and in the main application create a page that will render the partial pages.


Solution

  • Is there a way I can find out programmatically the number of areas that are present and their names

    No AFAIK currently there isn't an easy and reliable way to do this. In ASP.NET MVC 4.0 though there will be, I promise :-)

    Currently you might need to use reflection and look at all namespaces containing Areas.something and count them. Not very reliable.