Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the goals and benefits of using areas?

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.

like image 420
testCoder Avatar asked Oct 25 '12 12:10

testCoder


2 Answers

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

like image 184
avb Avatar answered Nov 08 '22 07:11

avb


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.

like image 39
VJAI Avatar answered Nov 08 '22 07:11

VJAI