Introduction to ASP.NET MVC

Introduction to ASP.NET MVC

First of all I would like to welcome any first time visitors to my blog. Before I start this blog I would like to give a brief introduction to myself. My name is Mark Anthony Farrugia and, apart from being a Computing Teacher, I am a freelance web developer based in Malta which is a small island in the Mediterranean. So now let me start this blog post :) .

In this blog I will cover ASP.NET MVC, which, in my opinion, is one of the best things that Microsoft have ever developed.

So let me start with some basic history on ASP.NET. The first ASP.NET version was out in 2001 and it was a complete revamp on the previous ASP version. At those days what Microsoft tried to do was to try and make web development as easy as developing desktop applications. They provided UI elements such as the gridview, repeater, drop down lists, list boxes etc which resembled other familiar controls which existed in desktop applications. One should remember that at those times desktop applications were by far the most common types of applications when developing enterprise applications. Microsoft felt that the tide was soon going to turn, and they felt that developers were soon going to choose web applications when developing their own enterprise applications. In fact they were right, because enteprrise web applications became very popular with the advent of server side web technologies such as ASP.NET and PHP.

I used to love programming in ASP.NET… but guess what…. now I feel that it does not suit me anymore with the advent of one of the best Microsoft technologies which is ASP.NET MVC. The main drawbacks of ASP.NET is the way how it renders its controls and the compatibility with different browsers. You end up having a gridview showing properly in Internet Explorer but not in other browsers such as Chrome or Firefox. Other problems I used to encounter was its difficulty in linking it with client side technologies such as Javascript and mainly JQuery. I also used to have big problems trying to integrate AJAX calls in my application, having to include controls such as the ScriptManager etc. Anyway no more on ASP.NET :)

I have been developing ASP.NET MVC applications for the past 3 years and I started with ASP.NET MVC 2. The current ASP.NET MVC version is 4 and you can find it here. ASP.NET MVC is an open source project and this is also a good move in the right direction. All the previous ASP.NET versions were a closed box, and I still remember having big problems when Microsoft used to publish a new version because of compatibility issues. ASP.NET MVC integrates tightly with client side libraries such as JQuery and in fact JQuery libraries are created the moment you create an ASP.NET MVC application in Visual Studio. For those of you who do not know anything about JQuery I will also cover this in further post in my blog.

So let’s start getting our hands dirty on ASP.NET MVC. Basically MVC stands for Model, View, Controller and its a completely different methodology on how web applications are developed. It’s important to note that MVC is not a Microsoft technology but rather it is a common design pattern or methodology which also exist in other languages such as PHP and Java. In the past years this methodology has become increasingly popular with web technologies. If you are extremly familiar with ASP.NET you might find ASP.NET MVC a little bit difficult at first. However, once you get the grasp of it I’m sure you will never look back.

MVC seperates the Presentation Layer, Business Layer and Application Layer in three different layers.

The Model can be considered as the place where the Business Layer is placed and one might find things such as database methods, LINQ TO Entities classes etc.

The Controller can be considered as the application layer and is the layer responsible for interacting with the Model and presenting data to the VIEW.

The View is then our familiar ASP.NET page and is the one responsible for presenting data to the user.

So enough theory…. In my next blog post I will guid you to create your first MVC .NET web application.