Using Areas in ASP.NET MVC Application


ASP.NET MVC relies on certain folder and class naming conventions to organize models, views and controllers. A large application often consists of functionally independent modules with the result that the main application is essentially a bundle of these sub-applications. In such cases, organizing various models, views and controllers can be tedious. Luckily, ASP.NET MVC allows you to split your application into what is known as Areas. Each area mimics the folder structure and conventions as required by ASP.NET MVC. This article shows you how Areas are used in an ASP.NET MVC application.

What are Areas?

Areas are functionally independent modules of your ASP.NET MVC application that mimic the folder structure and conventions of MVC. Consider the following scenario :

Areas are independent modules of your ASP.NET MVC application
Figure 1: Areas are independent modules of your ASP.NET MVC application

As you can see the main application has three functionally independent modules viz. Blog, Help Desk and Shopping. Without any areas in place, you would have put all the controllers and views in the respective folder of the main application folder. Obviously, you cannot have the same controller name for different modules. For example, you cannot have HomeController for Blog and HomeController for HelpDesk. You either need to put all action methods of both the modules in a single controller or create two controllers with altogether different names (say BlogHomeController and HelpDeskHomeController).

With areas in place, each module replicates the MVC folder structure. For example, each module will have its own Models, Views and Controllers folder. You can then have HomeController class in Blog module as well as HelpDesk module. So, in the above example, essentially you will have four MVC structures - one for the main application and one each for the three modules (Blog, HelpDesk and Shopping).

Adding a New Area

Before you work with areas, create a new ASP.NET MVC application with ASPX view engine. To add a new area right click on the application in the Solution Explorer and select the Add > Area shortcut menu option. Doing so will open "Add Area" dialog as shown below:

Adding a New Area
Figure 2: Adding a New Area

You need to enter the Area Name and click the Add button to create the folder structure for that area. The following figure shows the complete folder structure with three Areas - Blog, HelpDesk and Shopping - added.

Solution Explorer
Figure 3: Solution Explorer

As you can see, the main application has Areas subfolders. Inside the Areas subfolders there is a folder for each area you wish to create (Blog, HelpDesk and Shpping in the above example). Each Areaa subfolder has its own set of MVC folders (Models, Views and Controllers). You can treat each area just like the main application and add models, views and controllers in the respective folders.

Registering Areas with MVC Framework

Simply creating area folder structure is not sufficient, you also need to inform ASP.NET MVC framework about the areas you've added. Luckily, this task is automatically done when you add a new area. Notice the area registration class file that was created under each area folder (BlogAreaRegistration.cs, HelpDeskAreaRegistration.cs, etc.). The area registration file contains a class that inherits from AreaRegistration base class. The HelpDeskAreaRegistration class is shown below :

public class HelpDeskAreaRegistration : AreaRegistration
    public override string AreaName
            return "HelpDesk";
    public override void RegisterArea(AreaRegistrationContext context)
            new { action = "Index", id = UrlParameter.Optional }

As you can see the HelpDeskAreaRegistration class overrides AreaName property and the RegisterArea method. The RegisterArea method registers the route information for the newly added area with MVC framework.

You will have one area registration class file for each area. When are the area registration classes used? If you open Global.asax file, you will have the following code in the Application_Start event handler :

protected void Application_Start()

As you can see, there is a call to RegisterAllAreas() static method of AreaRegistration class. Calling RegisterAllAreas() method in turn invokes the RegisterArea() method of all the area registration classes found in the application.

Before going ahead, add HomeController to all the areas and the main application, i.e. four controller classes with name HomeController. All the HomeController classes will look like this :

public class HomeController : Controller
    public ActionResult Index()
        return View();

Then right click on each Index() action method and add Index view, i.e. total four Index views in their respective folders.

Run the application and try navigating to different areas. The following figure shows a sample run for HelpDesk area. Notice the URL of the area.

Run the Application
Figure 4: Run the Application

Linking Between Two Areas

ASP.NET MVC Views often need to link to some action method residing in controller classes. Unless otherwise specified, action methods and controllers are assumed to be from the current area. In case you wish to link to an action method belonging to some other area, here is how you would do just that:

<h3>You are inside main area. To navigate to some other area please click on the following links</h3>
<%= Html.ActionLink("Main Area", "Index", "Home", new { area = "" }, null)%>
<br /><br />
<%= Html.ActionLink("Blog Area", "Index", "Home", new { area = "Blog" }, null)%>
<br /><br />
<%= Html.ActionLink("Help Desk Area", "Index", "Home", new { area = "HelpDesk" }, null)%>
<br /><br />
<%= Html.ActionLink("Shopping Area", "Index", "Home", new { area = "Shopping" }, null)%>

The above fragment is from the Index view of the main area. It renders four hyperlinks using ActionLink(). Notice the fourth parameter that specifies area name. This parameter governs the area whose action method is being linked to.

Redirecting to an Action Belonging to Another Area

You can also redirect to some action method of a specific area using RedirectToAction() method. Consider the following action method:

public ActionResult Index()
    return RedirectToAction("Index", "Home", new { Area = "HelpDesk" });

As you can see, the Index() action method of the main area redirects the control to Index() action method of the HelpDesk area.


ASP.NET MVC allows you to organize your application into areas. Each area replicates the MVC structure and can be treated as independent as far as models, views and controllers are concerned. An area is registered with MVC framework using an area registration class and RegisterAllAreas() call in the Global.asax file.

About the Author

Bipin Joshi

Bipin Joshi is a blogger and writes about apparently unrelated topics - Yoga & technology! A former Software Consultant by profession, Bipin has been programming since 1995 and has been working with the .NET framework ever since its inception. He has authored or co-authored half a dozen books and numerous articles on .NET technologies. He has also penned a few books on Yoga. He was a well known technology author, trainer and an active member of Microsoft developer community before he decided to take a backseat from the mainstream IT circle and dedicate himself completely to spiritual path. Having embraced Yoga way of life he now codes for fun and writes on his blogs. He can also be reached there.



  • Regarding MVC Folder structure

    Posted by Kashif on 07/12/2015 06:38am

    Area I am finding difficulties to arrange the area folder for my project This is Job application website and having mainly following type of pages/section 1) - Admin Pages - Only for Admin user(site owners) - so only authenticated(logged in) admin users case see those pages/section example - Post_Jobs_Page, Edit_Job_Page, Change_Admin_Password, Add_News_Events_Page etc. 2) - Job seeker Pages - only for Job seekers - so only authenticated(logged in) Job Seeker users case see those pages/section example - change_Password, Edit_Profile, Applied_Jobs etc 3) - Common Pages - where any job seeker either authenticated(logged in) or without authentication can visit those page Search_Jobs, ContactUs, AboutUs etc So I am not sure how to organize MVC folder structure - how may areas should i add and where to put which files Please help Thanks, Kashif

  • layout in area

    Posted by massimo on 05/19/2015 03:45am

    hi, how it's possible to load a layout created in my area ? br max

  • Software Developer

    Posted by Saeid on 04/11/2015 03:55pm

    Thanks, Perfect Explanation, It was really helpful.

  • 女士

    Posted by savage wames on 07/20/2013 02:58am

    There is no doubt about the fact that vans en ligne help you protect your feet. At the same time, they give you style. When you have a good collection of shoes, you feel quite confident. You have shoes that are used for everyday activities. You might also prefer to wear different footwear or boots for playing some games.Then it is quite possible that you also have some special shoes in collection for special occasions. However, when the collection is not well organized, you may feel lost in front of the footwear. Getting the right footwear from the collection may be quite time consuming. You can make use of some organizing ideas to make the collection useful and aesthetic. You should start by examining your own acheter vans boutique size. The proportion you need to look out for is simple: for those who have slim ankles, don't select larger shoes for they will certainly come loosened and impair your movements. People with healthy ankles, however, should not purchase a size that fits them too securely for this could cut-off the blood circulation to the foot, evolving into more serious medical problems. Your shoe has to be the right size, neither a size bigger nor a size smaller. Likewise, the toe size of the shoes needs to be exactly correlated to your own. Padding is an additional problem in terms of deciding on the shoes. It is said that the older you are (or the heavier) the greater cushioning in your shoes you would likely need. Good quality and often fairly expensive squash shoes will give you amazing padding, else insoles and particular squash socks are there to help you along. Before choosing anything, you need to explore the size info on the product properly. But the huge assortment of Adidas, Harrow, Asics, Ashaways, Dunlop, karakal, Hi-Tec, Prince and so many more may bamboozle you. We will proceed to go through them now. There are so many styles of vans femme pas cher you can choose for a night out on the town, so to make the right decision when it comes to style, you have to consider your outfit, what you are going to be doing, and where you plan on wearing the shoes. Not only will this help you choose the best fit, it is also going to allow you to compare a number of fine styles and great shoes, no matter what you eventually choose to wear, or what unique style you want to go out with for the evening. If you are looking for a sexy black or sleek red, or if you want something with various colors, and unique designer prints and styles, when you choose to shop with the top name brand manufacturers for your new shoes, you will find hundreds of fine styles to try out, and you will find a great pair for any occasion and any location you plan on going out to for the evening. The scientific evidence is quite clear on many of the biomechanical effects of these vans pas cher. They have been shown to increase activity of the muscles and they have been shown to alter the biomechanics of the walk in people using them. While these changes are clear, what the evidence is not clear on is if the outcomes associated with changes that really are only theoretical. For example, there is no doubt that the muscles do tend to work harder when using these shoes, but there is no evidence that this will lead to an increased tone up. There is also no doubt that these shoes do alter the gait, but there is no evidence that this change is either a positive or a negative change. The marketers have taken the laboratory based biomechanical research and speculated a theoretical outcomes change to hype up what these shoes can do. In the extreme cases, there have been claims that they can cure cellulite and improve the circulation. It was this leap that got the companies in trouble with the regulatory authorities.

  • Savez-vous comment nettoyer un GHD Styler?

    Posted by uzebob549 on 07/16/2013 04:19am

    Le ressort de la boutique, il est beaucoup Cheap GHD Norge.Our lisseur ghd pas seulement pas cher mais la qualité est Veldig soutien-gorge, est la meilleure product.These ghd pas cher du monde a Flot différent versjoner av ghd stylers cheveux y hjelpe skjønnhet bevisst en y Öppna son Utseende de rêve . Ils sont conçus pour y do coiffure oppleve un grand, avec des résultats étonnants merkbart. Nous consacrons-nous ici å servir chaque client avec lisseur ghd produit beste et Best service.and ces ghd droit Rod Price mer tiltrekke you.We pense que vous nageoire vos lisseur ghd pas cher de favoris. [url=]ghd pas cher[/url] Lisseur avec la technologie de pointe dans la kératine, assurez-vous de protéger l'éclat naturel de vos cheveux tout en style. Il est prêt à l'emploi indicateurs, les paramètres numériques avec réglable varmed pour obtenir un revenu régulier et un système de verrouillage simple pour oppbevaring.Profesjonell pratique simplement serrer avec plaques extra-longues pour un maximum d'impact sur ​​la température long / plein hÃ¥r.Tilpass pour cheveux céramique ditt.Høyresistent revêtement avec tourmaline pour de meilleurs résultats. [url=]ghd lisseur[/url] La société a lancé la série des redresseurs avec finish.The lisseurs GHD classiques brillant et élégant sont généralement publié en finition mate et est livré soit en rose en édition limitée ghd ou noir standard. Pour faciliter tout en style, le produit a été conçu avec l'attachement de cordon pivotant afin que le noeud du cordon de votre outil de cheveux restera libre que vous le style. Une distribution uniforme de la pression sur les cheveux est réalisée par la fonctionnalité de plaques flottantes du redresseur.

  • converse skorarticle

    Posted by tvndmiuc on 06/21/2013 12:15pm

    If you would like mens striped glow during the dark socks you'll have to make them on your own with fabric markers or material pens. Now glow within the dark usually signifies they glow underneath black light, or they need to have black light shine on them for you to glow to get a although. So observe what you invest in and study the description. I've also incorporated some neon markers also as glow while in the dark markers considering neon markers will give a glowing effect during the day underneath normal lighting disorders. That is the sole way I could discover up to now so you can have glow inside the dark stripes or neon stripes on your socks. Trumpette Youngsters GLOW-in-the -Dark Lady SOCKS Maryjane Mary Jane DOT Neon Green Pink Blue 3 prs present Dimension 5-6 Glow while in the Dark Socks CW-X Unisex Adult Ventilator Compression Help Socks Thorlo Women's Lite Running Micro-Mini Low-Cut Sock Thorlo Unisex Thick Cushion Running Rolltop Sock If you would like make your own personal glow within the dark working socks you will need plain white socks, and a few glow inside the dark paint. You can actually either spritz it on, or you could place it within a spray bottle and spray it on if it doesn't come in a spray can previously. Tulip Material Spray Paint, that is a everlasting fabric paint dries to a terrific colour, is soft and flexible and doesn't fade away or disappear right after repeated washings. Basically spray these glow or neon paints onto your fabric and allow it dry for 24 hours to get a long term, machine-washable shade. Spray freehand, apply to crumpled material for intriguing patterns, or you can use stencils. A different intriguing technique to decorate your socks could be to produce watercolor effects by applying to dampened material. Greatest once you pre-wash your socks initial, and use white or light colored socks. I have integrated some neon paints also as these will demonstrate up through the day light hours and appear to glow. Thorlo Women's Lite Working Mini Ankle-Cut Sock Glow in the dark socks for little ones can be a challenge to find but I have collected some good sets to suit your needs to appear at these days. You can go through critiques of any items on this web page by only clicking on any with the hyperlinks. And don't overlook to verify the availability on totally free super conserving shipping. I have listed some certainly sharp searching neon socks under instead of glow inside the dark socks for men and women alike. Tulip Material Spray Pack - Neon Colours - Set of 4 Colors Tulip 29069 Fabric Spray Paint, 9-Pack Assorted Colours

  • Bright Mother of Pearl Dial with Diamonds Watch.

    Posted by Ricsninny on 06/20/2013 11:17pm

    レディースウォッチ異なるデ [url=]カシオ 腕時計[/url] ザイン。インクルードまた、構成 [url=]シチズン 腕時計[/url] されています組み込むもずっと等 [url=]グッチ 時計[/url] 同じ多機能メンズ腕時 [url=][/url] シチズン 腕時計 計を。これらの時計は、 [url=]オークリー サングラス[/url] さらにもなる銀メッキま [url=]オークリー ゴーグル[/url] たは金メッキそれを作ること活気望 [url=]オークリー レンズ[/url] ましいすべてへのいずれ [url=][/url] オークリー サングラス かまたはすべてにすべてま [url=]セイコー 腕時計[/url] たはいずれかへ。 Oneフェミニンスタ [url=]セイコー 時計[/url] イルカシオの時計はが有 [url=]seiko 腕時計[/url] 名なカシオWaveseptor時計。時 [url=][/url] seiko 腕時計 計の次のカテゴリがされるがありますでしょう [url=]シチズン 時計[/url] カシオの高級時計コレクション。 ものこれら [url=]セイコー 腕時計[/url] は最も高価な最も貴重で最も高価です。非常に一般 [url=]カシオ 腕時計[/url] 的な例カシオス [url=][/url] セイコー 腕時計 トリートライダーです [url=]ラルフローレン[/url] つまりの最高の仲間に関してへジ [url=]ポロラルフローレン[/url] ョギングやスポーツマンに [url=]ラルフローレン ポロシャツ[/url] 関係|を取得する。また、す [url=][/url] ポロラルフローレン ることができますで利用岩または都市地形登山者やバイカー周り全体に。

  • converse skor reanews

    Posted by whuzziqf on 06/16/2013 11:29pm

    You will find now two operating playlist possible choices. 1 is Indie rock, Funk, and Jazz and the other is much more intense, face-punching trash, metal, rock using a minor ska. You have got the capability to pick your BPM after you download the songs (ie. 140, 145, 150, 155, 160, 165, 170, 175, 180, 185 BPM). The tempo is constant throughout the song so it is amazing for lengthy runs. It really is unique music played w/ serious instruments, not a standard techno remix track. Preferred Operating Music for any Marathon Complete Disclosure: I made these playlists. So certainly I'm listing to start with :) I researched these songs very carefully and just about every song is both exciting, motivational, or precise to working. They may be also two - three hrs lengthy to cover almost all of a marathon. In addition, they start w/ slower BPM then construct to speedier songs since it will get to the end. They may be eclectic mixes of alternative/progressive rock, traditional rock, indie music, some R hop and 80's power-pop. You will discover bands like the Clash, Stones, Gorillaz, the Police, Killers, Kooks, White Stripes, Arctic Monkeys, OutKast, Vampire Weekend, Doors, the Smiths, XTC, etc. Working to music with as well slow of a tempo could cause you to subconsciously decelerate on the beat. Acquiring the perfect beats per minute (bpm) for your working music can enhance your overall performance. I am not a runner, but I've spent quite a lot of time building running playlists for my wife who has run a number of marathons. In accomplishing so, I grew to become aware of the significance of the bpm of a song and how it relates for your working speed. A lot of us prefer to run to "Eye from the Tiger", but at 109 bpm, it can be way as well slow. Any time you run to music which is also slow, you may subconsciously decelerate to your beat of your song. There have also been several scientific research finished that present that acquiring the "right" music truly improves your perfromance. Another problem with many of the running playlists on the market is the fact that the lyrics are just not motivational. I see working playlists w/ "Blister inside the Sun" or "19th Nervous Breakdown" and though they could have great bpms, it just does not seem to be like everything you want for running music while in the middle of 26.2 miles. So here are a list of web sites that combine good music, bpm, and motivational songs:

  • wheloltabotly PumeSonee Phobereurce 4410346

    Posted by TizefaTaNaday on 06/13/2013 05:08am

    oscixSeiggire Plauradah Witesonsink

  • Vælg Beats by dre du ved, du valgte den rigtige

    Posted by wherewanzi on 06/05/2013 09:26pm

    [url=]Beats by dre danmark[/url] Hestekræfter samt reggae hele verden har kombineret såvel som resultatet er den nye Doctor Dre laptop. Med ferier her og også Dr. Dre laptop annoncer viser konstant på tv, er alle spekulerer på, om de skal købe det faktiske H. s.. Misundelse (den bestemte specialiserede navn med den personlige computer).Over-the-ear hovedtelefoner er fantastisk for ejendom bliver opmærksomme samt vejledning i at lukke ud lyde som du sover. On-ear typer bør også være behageligt, sammen med delikat ekstra polstring og robust konstruktion. Bare om de mest væsentlige ting sammen med on-ear design er at sikre, at de er installeret til brug sammen med stikkene i dine gadgets. [url=]Køb høretelefoner billig[/url] Det kan ikke være potentiel, at du er en total musik-freak, og du måske ikke tænker højtydende trådløse hovedtelefoner! Disse gadgets er de korrekte kammerater specielt inde du lytter til musik bestræbelser. Der er en række organisationer, først og fremmest de velkendte mærker, som Sony, Philips og Samsung osv., der tilfældigvis er i massiv organisering af elektroniske varer og tjenesteydelser og hovedtelefoner med Monstor Diddybeats White trådløse bestemmelser er en af dem. Du vil finde bestemte funktioner og faktorer, som har at blive alvorligt tages i betragtning, når 1 vælger denne fantastiske enhed. Målet er normalt at støde på en sund god kvalitet, der er helt sikkert virkelig vidunderlig og afslappende mod sindet også. [url=]beats by dre danmark[/url] If inline controls for calls is a priority, consider checking out the RHA SA950i, which is even more affordable, and also has a more substantial bass response in comparison. The Polk Audio UltraFit 2000 is another budget on-ear option—more affordable than the Zoro with phone controls built into the earpieces, and as a bonus, it’s intended to withstand sweaty workouts. If you have a bit more room in your budget and still want an emphasis on clarity in the mids, and bass that isn’t wildly boosted, the Bowers & Wilkins P3 is a comfortable on-ear option with solid audio performance.

  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date