Areas in ASP.Net MVC 5

When we create a new MVC project then Model, View and Controller folders are created automatically.

This structure is common for simple applications, but when your application grows and becomes complex then the single Model, View and Controller can become complicated. So we can maintain a complex MVC application using areas. Using areas, we can write more maintainable code for an application cleanly separated by the modules.

So first create a new MVC empty project.

Then right-click on Solution Explorer and click on add and select area.

add area

Provide a name.

Give Name

Now add a second Employee area. In your Solution Explorer show your Model, View and Controller in a different student and employee area.

add second Employee area

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

Now run the project. (Ctrl+F5).

For the Teacher area the follwing is the URL localhost/Teachers/Home/Index.

Here Teachers is the area name, Home is the controller and Index is the Action name.

index

For the Teacher area the follwing is the URL localhost/Students/Home/Index.

Here Students is the area name, Home is the controller and Index is the Action name.

Action

Up Next
    Ebook Download
    View all
    Learn
    View all