TOC

The community is working on translating this tutorial into Nepali, but it seems that no one has started the translation process for this article yet. If you can help us, then please click "More info".

Introduction:

What is MVC?

MVC, short for Model-view-controller, is a software pattern originally developed in the 1970's when graphical user interfaces were in the very early phases of development. MVC strives to separate an application into three areas:

The Model

This is where data and business logic is stored. In a typical web application, this part of the application would represent e.g. a database table or any other object that your application should deal with.

The View

The View is the actual visual representation of your Model. In a typical web application, this would be the page that shows your Model to the user, whether it be a form for inputting the data or an output of the data or a combination of both. Obviously, a View doesn't have to show all parts of the Model, and a Model can have more than one View.

The Controller

The Controller should handle all communication between your Model and your View. In a typical web application, the methods of the Controller are invoked by the user when a page is loaded or a button is clicked. The Controller then updates the Model, if necessary, and then returns a new View (or action, but more about that later), if necessary.

The Rise of MVC

After being introduced in the 1970's, the MVC pattern didn't get much attention for the next 30 years. Early web languages, like Perl, PHP and ASP Classic didn't really focus on design patterns and even with the release of ASP.NET, MVC was still not an integrated part of it. Sure, you could apply MVC techniques to your projects, but none of the popular frameworks encouraged it in any way.

Then, in 2004, the Ruby on Rails framework was released, which was a web development framework based on the Ruby language with heavy inspiration from the MVC pattern. A lot of people believe that this put the focus back on MVC and shortly thereafter, many PHP frameworks, centered around the MVC pattern, was released. All of this made the MVC pattern hugely popular, which is probably why Microsoft decided to do an implementation of it for their .NET framework, including massive tool support in their Visual Studio IDE. ASP.NET MVC was released in 2007, but the first final version didn't see the light of day before 2009.

In the next chapters, we will look deeper into what ASP.NET MVC is all about and how it compares to the alternatives, mainly ASP.NET WebForms.


This article has been fully translated into the following languages: Is your preferred language not on the list? Click here to help us translate this article into your language!