Click here to Skip to main content
12,553,933 members (64,548 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


18 bookmarked

Using areas in ASP.NET MVC to organize a project

, 3 Jun 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
How to organize an ASP.NET MVC project using areas.


When we work with ASP.NET MVC, we find some default folders (view, model, controller, and some more), but if the application is big, it is complicated to maintain a structure logic for the files and modules for the site. To solve this problem, ASP.NET MVC provides a powerful feature called areas, with areas it is possible to "isolate" the modules of your site.

Using the code

First step: create a new ASP.NET MVC 4 application, I recommend to use the basic template.

Next step: Over the project name, right click -> Add -> Area, and assign a name to the new area, when the area creation ends, we see a new folder called Areas, and within this folder you can see a folder with the name of your area and some files, think that an area is a mini-MVC project within your principal project.

The next image shows how it looks if you create an area called Reportes:

An important file that is created too, is ReportesAreaRegistration.cs, this file is used to configure the routing system for the area.

public override void RegisterArea(AreaRegistrationContext context)
        new { action = "Index", id = UrlParameter.Optional }

Also, in Global.asax, on the Application_Start method the configuration for the areas is called:


Now, if you run the application, you received an error that says:

The request for ‘Home’ has found the following matching controllers:

This error is produced because you have two controllers with the same name, but the solution is easy, go to the function RegisterRoutes of the class RouteConfig and add a namespace:

    name: "Default",
    url: "{controller}/{action}/{id}",
    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
    namespaces: new[] { "Areas.Controllers" }

I hope this post will be useful for you!


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior) BDotNet
Colombia Colombia
Microsoft ASP.NET MVP, I love software development, especially web development, I have worked with Microsoft technologies for about five years in the development of large scale enterprise applications, co-creator of several Carreras for the Microsoft Virtual Academy (MVA), speaker at events Microsoft Colombia and member of the Core Group BDotNet community. You can see some of my contributions in

You may also be interested in...


Comments and Discussions

Generalnice quick explanation Pin
Member 1029511527-Sep-13 0:38
memberMember 1029511527-Sep-13 0:38 
QuestionAreas are a bad move Pin
jphamilton3-Jun-13 6:12
memberjphamilton3-Jun-13 6:12 
AnswerRe: Areas are a bad move Pin
Member 85284093-Jan-14 9:12
memberMember 85284093-Jan-14 9:12 
AnswerRe: Areas are a bad move Pin
lukasz.f9-Apr-14 5:43
memberlukasz.f9-Apr-14 5:43 
GeneralMy vote of 4 Pin
asp_crazy_guy2-Jun-13 23:07
memberasp_crazy_guy2-Jun-13 23:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161021.1 | Last Updated 3 Jun 2013
Article Copyright 2013 by julitogtu
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid