Chapter 21. Organization with areas
This chapter covers
- Organizing large applications with areas
- Creating links between areas
- Managing global, area-agnostic content
- Managing links and URLs
As ASP.NET MVC websites become larger and more complex, the number of controllers inevitably grows. With a large number of controllers, we start to notice many controllers that might logically belong together as a group. We might have administration sections of our application, product catalog sections, customer care sections, shopping cart and ordering sections, and so on. Each of these application areas will likely share nothing more than perhaps a common logon widget or a master page, but each application area probably has quite a lot of functionality in common with other controllers and views within that area.
To help tame large applications, ASP.NET MVC 2 introduces the concept of areas. Areas allow us to segregate controllers, models, and views into different physical locations, with the area-specific pieces in a single area folder. In this chapter, we’ll examine using areas to separate our application’s different concerns. We’ll also use T4MVC templates to help us generate our URLs and links between areas.
To create our first area, we can start by right-clicking the project in the Solution Explorer and selecting Add > Area, as shown in figure 21.1.