ASP.NET MVC Introduction

ASP.NET MVC is Microsoft's Web development framework targets .NET Framework. If you want to build a Web application using .NET Framework, C# or VB.NET, ASP.NET MVC is the way to go. In this article, we will cover the following,
 

Table of Content

  • Introduction
  • Model-View-Controller
  • Advantage of MVC Pattern
  • ASP.NET MVC vs Web Forms
  • Conclusion

Introduction

 
This article explains what MVC is and why to use ASP.NET MVC instead of ASP .NET Web Forms. MVC stands for Model - View - Controller. It is a software architecture pattern that separates the representation of information from the user's interaction with it. Model View Controller has been widely adapted as an architecture for World Wide Web applications in all major programming languages.
 
ASP.NET supports three development models: Web Pages, MVC and Web Form.
 
MVC-Introduction1.jpg
 

Model-View-Controller

 
MVC consists of three kinds of objects (Model, View and Controller). The Model is the application object, the View is its screen presentation, and the Controller defines the way the user interface reacts to user input. Let's see each of them in brief.
 
Controller
 
The Controller is an input control. It first executes when the user sends a request. Then the action determeines which view will be shown. It connects to both the View and the Model. It can send commands to its associated view to change the view's presentation and can also send a command to change the model's state. It processes in the way that it reads data from the view (controls user input) and sends input data to the model. A controller can be associated with multiple views, in other words we can define multiple actions in a controller and depending on the action, an associated view is shown. It is the principal part of the MVC architecture. It is similar to the Business Layer of 3-tier architecture.
 
Model
 
A Model is associated with Views and a Controller. It produces the updated output on the view. Often the model objects retrieve data from the database and stores data to the database. It handles the logic for the application's data domain.
 
View
 
Views are the components that display the application's User Interface (UI), in other words it manages the displays of information. Often the views are created from the model data. We can attach multiple views to a single model to provide a different presentation (View/Model decoupling).
 
MVC-Introduction2.jpg

Advantages of MVC Pattern

 
There are the following advantages of the MVC pattern:
  1. Business Logic is independent so it can be used from different presentation tiers.
  2. Application divided into three the categories of input logic, business logic and UI logic so it is easier to manage complexity of the application.
  3. It does not use viewstate and postback.
  4. It provides better support for test-driven development (TDD).
  5. By separating concerns into 3 distinct pieces (Model, View and Controller), we also facilitate true unit testing. Our Presentation Layer can be tested free of the Model or Controller, and vice-a-versa.

ASP.NET MVC vs Web Forms

  1. Web Forms embraces the RAD philosophy whereas ASP.NET MVC is TDD-oriented.
  2. ASP.NET Web form uses server controls but ASP.NET MVC depends on HTML Controls.
  3. Web application development with Web Form is easy compared to ASP.NET MVC because ASP.NET MVC web application requires experts in HTML and JavaScript.
  4. The web application is a lighter application with ASP.NET MVC architecture compared to ASP.NET Web Forms because ASP.NET Web Form applications store the view state on a page so it becomes heavy and reduces performance.
  5. ASP.NET MVC provides powerful URL mapping so it is better for SEO.

Conclusion

 
The MVC pattern has many advantages by separation of input logic, business logic and UI logic but has some drawbacks that it is fully controlled by HTML, JavaScript and CSS and can't easily learn without experiments.
 


Similar Articles