Areas in MVC 5

In this article, I am explain how to use area in MVC.

When we create new MVC project then Model, View and  Controller folder create automatically.

This structure is comman for simple application. but when your application gets big and complex then single model, view and controller can get complicated.So we can maintained complex mvc application using area.Using areas, we can write more maintainable code for 
an application cleanly separated according to the modules.

SO First create new mvc empty project.

Then Right clcik on solution explorer and click on add and select area.


area in mvc


Give Name.


Area

now add second Employee area. In your solution explorer show your model, view and controller in diffrent student and employee area.


Area in mvc

Now add Home Controller and in Index action add Index View for both student and employee area.

Now Run Project.(ctrl+F5).

For Teacher area follwing url localhost/Teachers/Home/Index
Hear Teachers is area name, Home is controller and Index is Action name.


Area in mvc

For Teacher area follwing url localhost/Students/Home/Index
Hear Students is area name, Home is controller and Index is Action name.


Area in mvc


Post a Comment