Create Areas in the MVC project

Introduction to Area

Areas are logical grouping of Controller, Models and Views and other related folders for a module in MVC project.

Steps to create

Step 1: Create a new MVC project in the visual studio





Step 2: Right click on the project and Add Area

Screenshot (6).png

Screenshot (7).png

Screenshot (9).png

MVC automatically adds a full structured folder in the Area1 with the code of “AreaRegistration” for MVC to auto register  Area when project is Run.

Step 3 : Add new controller in the new area


Step 4: Add new View to the Index action method in controller


Step 5: Run the application and to access the view in the area follow the following syntax

http://localhost:{port number}/{Area Name}/{Controller Name}/{Page Name}

Screenshot (15).png

This helps in many ways:

  1. Separate the Large code into small modules
  2. Keep code maintainable
  3. Divide a Big Project into multiple small Logical Areas (Each as One Module)
  4. Add remove modules on demand

I have been working with Areas to design many different Architecture Design that helps in modular design plug and play module even during the runtime and deployed Instance on IIS.

Try yourself and happy to share.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.