jettore.blogg.se

Area models
Area models







area models

There may be name conflict for controller if modules need to have the controllers with same name.You have to create the same folder structure in every top level folder that mean inside Views, Models, Scripts, and Images, etc. The nature of functionality of modules may be different (there would be less scope of shared code) and you may need to categorize CSS, scripts, models and other related functionalities for modules too.As shown below:īut using such approach for divisions, we may face the following problems in large applications: Debate on Alternate Approachįew people can argue that instead of using Area to divide the code as per modules in application, we can make folders structure in top level Controllers/Models/Views folders. Using areas, we can write more maintainable code for an application cleanly separated according to the modules. By convention, a top Areas folder can contain multiple areas. Areas are logical grouping of Controller, Models and Views and other related folders for a module in MVC applications. In such cases, Areas help us to organize the code. For large applications, we often face such problem to organize the code effectively. As the number of controllers and views grow, we feel the need of grouping the controllers and views. This approach works well for small applications having less number of controllers and views. Finally in top level Models folder we have models which manages the behaviour and data for the application domain. Corresponding to Action names in controller, we have view files (.cshtml file) in it.

area models

Inside top level Views folder, there are folders, corresponding to controllers (having the same name), and containing views files for the controller. In Controllers folder we can have several controllers, each of them is focused on specific group of functionalities.

area models

In this article, we will learn the concept of Areas and how to use it with a practical scenario in ASP.NET MVC 4.īy convention in ASP.NET MVC project template, to separate application code based on responsibilities, we have top level folders as Controllers, Views, and Models.









Area models