What are the goals and benefits of using areas?
Asked Answered
N

2

12

I have question about benefit of using areas and necessity of them.

I see some opposites:

  1. MVC patterns have routes, and they need for escaping out of folder structure.
  2. But when we using areas we create folders which maps to routes. And result of it is that we finally return again to folder structure?

Does really needed areas in mvc application, because they force us to return to folder structure.

Which goals of using areas in asp mvc? Which benefits of using areas.

Napkin answered 25/10, 2012 at 12:50 Comment(0)
I
7

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.

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.

Content from: http://www.codeguru.com/csharp/.net/net_asp/mvc/article.php/c20227/Using-Areas-in-ASPNET-MVC-Application.htm

Incrustation answered 25/10, 2012 at 12:54 Comment(2)
Does each area should use his own database, do i have a ability use single db for all areas?Napkin
Indeed, you can use one database for all your areas.Incrustation
H
2

Areas helps you to group controllers (and their related models and views).

In smaller applications, mostly you need a single controller to wrap up all the actions required by a single module. When the functionalities of the module increases (usually in big applications) you add more actions to the controller and obviously it becomes FAT. At that time, you start to think to break the poor FAT controller into smaller ones. Now these group of smaller controllers is an ideal candidate to transform into an area. Since now all controllers, views and models of a module are in a single place you can manage them quite easily.

Herbart answered 25/10, 2012 at 13:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.