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.

21.1. Creating a basic area

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.

Figure 21.1. The Add > Area context menu option

21.2. Managing links and URLs with T4MVC

 
 

21.3. Summary

 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest