Home > .Net / C#, Asp.Net MVC, Web Services > What’s New in Asp.Net MVC 4 ?

What’s New in Asp.Net MVC 4 ?

January 30th, 2013 Leave a comment Go to comments

Introduction

In the last 2 years I’ve been working on a complex Asp.Net MVC 3 based solution, utilizing the whole Asp.Netstack, a hybrid application, combination of desktop and mobile experience and a tremendous amount of javascript. And I liked it. That's why I decided to create a series of articles related to Asp.Net MVC, starting with this one.

So what’s new in (the not-so-new) version 4 of the framework ? Let’s check the most interesting features.


The Asp.Net Web API

Ever worked with web services, WCF maybe ?

Asp.Net Web API is the new kid in town, based on REST (actually based on OData, check my article on web services) and Asp.Net MVC. It’s a web services framework. Like WCF, but with the core Asp.Net MVC inside. We found out that MVC was good at serving non-html content, we actually started to use it for that purpose especially when working with browser APIs. That was one of the reasons the Asp.Net team decided to strip the unneeded part and leave only the service-related modules into the Web API.

It includes some of the basic Asp.Net MVC functionality, such as:

Routing:
The same convention over configuration mapping that Asp.Net MVC provides.

 

Model binding and validation:
The same model binding functionality, but suited for HTTP-specific context related operations.

 

 

Filters:
The Web API uses a lot of the MVC build-in filters. I really love to use aspect–oriented programming provided out of the box.
 
Unit testability:
Based on MVC, it’s truly unit testable. (check my unit testing introduction article)

 

Richer mobile development support

Asp.Net MVC 4 introduces features targeting mobile device development. It’s the so called hybrid design, utilizing HTML and CSS with the mobile browser, eliminating the need for hardcore Java (Android, Blackberry, J2ME), Objective C (iPhone), C++ (Symbian, my favourite), etc. Or at least mitigating the need for it, I’ll write an article for that when I come to this.

Anyway, a lot of handful CSS and Javascript files are now inside, including JQuery Mobile.

 

Bundling and minification

We now have a build-in bundling and minification support.

Bundling is the process of “bundling” a set of javascript or CSS files together with the idea of limiting the requests made to the server.

Minification is a content optimization technique used with javascript and CSS files. It removes comments, unnecessary spaces, new lines, renames long variable names, etc., so the size of the source can be reduced and with that increase the throughput of the network medium.

 

Included open source libraries

Libraries like JSON.Net and DotNetOpenAuth are also included in the sources.

 

Asp.Net MVC is now truly open source

Although the source code of version 3 was legally downloadable, we were able to read it, modify it and even redistribute it, we weren’t able to contribute our changes back. Now it’s possible, you can freely commit changes at codeplex, which are a subject of verification of course.

 

The configuration logic is no longer in Global.aspx

It is moved to static classes in App_Start for manageability reasons.

 

Empty MVC project template

There is a new empty MVC project template, which is now really empty, without the bunch of javascript files included before.


Custom Controller location

Custom locations for the controllers are now supported. In MVC 3, your only chance was to place your controllers inside the Controllers folder.

 

Real time communication

There is now support for Web Sockets and the new open source framework called SignalR. It’s used for a continual real time communication through open TCP sockets. I’ll write a separate article for this feature.

 


That's the general changes included in Asp.Net MVC 4. I plan to write a series of articles related to Asp.Net MVC, so stay tuned !

Speaking of new things, I recently wrote an article related to the new features in Entity Framework 5. You can check it out here : What's new in Entity Framework 5.0

Thanks for reading. ;)


About the author:
Kosta Hristov (34 Posts)

Hi there ! My name is Kosta Hristov and I currently live in London, England. I've been working as a software engineer for the past 6 years on different mobile, desktop and web IT projects. I started this blog almost one year ago with the idea of helping developers from all around the world in their day to day programming tasks, sharing knowledge on various topics. If you find my articles interesting and you want to know more about me, feel free to contact me via the social links below. ;)




Like the article ? Share it ! ;)


Current month ye@r day *


Copyright © Developing the future 2013. Licensed under the CC BY-NC-ND 3.0 Creative Commons license.