When Written: April 2012
The other announcement is that the source code of ASP.NET Web API and ASP .NET Web Pages ( Razor ) has been released to Open source, these join ASP .NET MVC which now will ship with jQuery, Modernizer, NuGet, Knockout and JSON libraries from the Open Source family. Not only is the code being released, but also for the first time Microsoft are going to be allowing developers to submit patches and code contributions. Obviously this code will be checked by the Microsoft development team before it gets anywhere near the code that you and I will use, but it is a great move by Microsoft to move out of its ivory tower and further involve and embrace the very talented developer community. In these days it is crazy not to take advantage of this active and skilled resource to improve your product, so I guess the surprise is not that Microsoft have made this move but that it took them so long to take this step. If you want access to this source code and all the submissions to it or perhaps you have some code you wish to submit then it is all listed on CodePlex (http://aspnetwebstack.codeplex.com/ ).
An alternative way of building ASP.NET applications is with the MVC framework
If you are a developer using Microsoft technologies and you haven’t tried the ASP.NET MVC framework yet, might I suggest that you give it a look. For those of you that don’t know, MVC stands for Model, View, Controller. That may not help some of you so apologies of those of you who do know, let me explain that these are three areas of an application that going to become a major framework of ASP.NET development, possibly replacing Web Pages. MVC is not an invention of Microsoft and if you have been programming you may be using something similar without knowing it.
Models are objects that hold the logic for your application; these could get data from your database, work on it and then write the new data back. With a small app this may be dealt with by the database with no physical Model object in your code. Views are as the name suggests the components that display the data in the application; you might for instance have an edit view of your data and a read only view of the same data. Controllers are the pieces of code that handle the user input so, for example, a Controller might take and manipulate a string value from a View which it passes to the Model which turns this value to a query to get data and return the result to another View. The reason for separating these three areas is to help in building applications and to make debugging and alterations easier.
All the UI logic should belong to the View whilst the Business logic belongs in the model. With this loose coupling between the three components each could each be developed by different teams safe in the knowledge that the whole application should work as intended and if it doesn’t then the area causing the problem can be found easily and blame accorded! MVC framework suits larger complex projects using teams of developers as well as giving you more control over the behaviour of an application. If you have ever tried adding extra JavaScript code to a web forms based web application to try and alter the behaviour of an object on a page you will know that it is often fraught with problems as the code from the web forms are built during page render and so conflicts with your own JavaScript code can not only often occur, but it can be tricky to see quite what is cause the problem.
This doesn’t mean that Web Forms are dead, far from it. They are more suited to smaller projects and are certainly less complex for application development but the code can be difficult to bend to your needs if they are significantly different to the default behaviour of the object that you are using. Either way MVC is worth checking out, it is free and fully integrated to Visual Studio so there really is no excuse – apart from there being not enough hours in the day of course !
Article by: Mark Newton
Published in: Mark Newton