Introduction to MVC

Introduction

The Model-View-Controller (MVC) is an architecture that is used by different technologies. Here “M” “V” “C” stands for “MODEL”, “VIEW”, and  “CONTROLLER" respectively.

You can also consider MVC (in terms of layer architecture) as:

i) The business layer (Model logic)
ii) The display layer (View logic)
iii) The input control (Controller logic)

MVC is an architecture not a technology or language. Most of the companies follow MVC design pattern while developing different types of application. You can use this architecture without independent technology or language.

In this tutorial, we will discuss about ASP.NET MVC. The ASP.NET MVC is a web application framework developed by Microsoft. This framework implements the model–view–controller (MVC) design pattern. It helps the developers to build well-structured web applications. Microsoft released ASP.NET MVC in 2007.

For developing ASP.NET MVC application, the minimum requirement is Microsoft .NET Framework 3.5. In ASP.NET, MVC framework is defined in the System.Web.Mvc assembly.

Components of the MVC architecture

The controller receives the user input, builds the proper model, and then passes it to the view. Both the controller and the view depend on the model. Model is unaware of the controller and view.

mvc

The MVC framework includes the following components:

Models: Model implements the logic for the application's data. Basically model is a C# or VB.NET class and it retrieves and stores model state in a database. Suppose that you have an Employee table in a SQL Server database. The Employee object might retrieve information from a database, use the information, and then write update information back to an Employee table.

Views: A view represents the user interface (UI) in your application. In general, your UI is mapped with model data. Suppose that your model data is employee object then you can create a UI that displays text boxes, drop-down lists,GridView and check boxes based on the current state of an Employee object.

Controllers: Controller is a heart of the entire MVC architecture. Controllers are the components that coordinate the link between the view and the model. Controller process the input, work with the model, and rendering the view. In an MVC application, the view only displays information; the controller handles and responds to user input and interaction.

The main advantages of ASP.net MVC are:

1. Enables the full control over the rendered HTML.
2. Provides clean separation of concerns (SoC).
3. It enables you to create test Driven Development (TDD).
4. Easy integration with client side script (example: JavaScript) frameworks.
5. Following the design of stateless nature of the web.
6. Support multiple views.
7. No ViewState and PostBack events
8. It enables you to manage complexity by dividing an application into the model, the view, and the controller.
9. The components of the ASP.NET MVC framework can be easily replaced or customized.
10. ASP.NET MVC Support for existing ASP.NET features such as forms authentication and Windows authentication, membership and roles, output and data caching, session and profile state management, etc.

For developing ASP.NET MVC application, you must have Microsoft .NET Framework 3.5 or higher. We have used .NET Framework 4 for developing the application.