ASP.NET MVC Architectural Pattern

Introduction

MVC is an architectural pattern. There are three main different components using Model, View and Controller. ASP.NET MVC pattern is lightweight.

See MVC Architecture
                                                      Figure 1.0

See MVC Architecture in the above figure 1.0

Model

  • Model is a part of the application data domain. Model consists of all the classes that handle data and business logic.
  • The Model is often a conceptual separation instead of the physical one.
  • Model retrieve and store state in database.

Controller

  • It handles user interaction.
  • Controller is the heart of the entire MVC Architecture.
  • Controller is connecting Model and View.
  • Controller communicate Model and view.
  • Controller handles user request and response.

View

  • View is an aspx page without having code behind file.
  • View display the application user interface.
  • UI is created from model data.
  • Once the data processing is complete the controller classes are a response to the user by sending the result to a view.

Advantages

  • It is easier to maintain complexity.
  • MVC framework ideal to developer full controller over the behaviour of the system.
  • MVC framework support Test-Driven development.
  • MVC framework is reusable.
  • Synchronized views.

Disadvantages

  • Increased Complexity
  • Inefficiency of data access in view.
  • Difficulty of using MVC with modern user interface too.

Create a ASP.NET MVC Application

  • For basic understanding see the following figure to create ASP.NET MVC application.

Step 1: Open Visual Studio,

Visual Studio
                                                                        Figure 1.1

  • Open Visual Studio and go to tab File, click New, and then Project.
  • Shortcut Key Ctrl + Shit + N.

Step 2: Select MVC Application,

Select MVC Application
                                                                     Figure 1.2

  • After selecting project open window and select ASP.NET MVC 4 Web Application.
  • Enter Application Name and set path.
  • Click Ok button.

Step 3: Select Template,

Select Template
                                                                           Figure 1.3

  • Different types of templates are available. You can select any one template.
  • Select View engine. There are two types of View engine 1. Aspx 2.Razor.
  • Click OK.

Step 4: See Controller

See Controller
                                                                             Figure 1.4

  • See Controller folder.
  • You can create own controller, then right click and add controller.

Step 5: See Model

See Model
                                                                                    Figure 1.5

  • See Models folders; you can create own classes in model folder.

Step 6: See View,

See View
                                                                         Figure 1.6

  • See View folder.
  • View Folders inside the folder to create design file.

Step 7: Run application and see the browser application.

RUN
                                                                        Figure 1.7

Note: If you have any question, then please mention in the comments section.

Up Next
    Ebook Download
    View all
    Learn
    View all