Every once in a while, I look at the date and wonder how fifteen years have passed since I graduated high school. Looking back at those four adolescent years, they feel more like four decades. It is crazy to experience the speed of life.

The software we build wonders the same thing. Has it really been seven years since that website was built? Wasn’t it just yesterday that Ajax was the thing of the future, and IE 7 was the greatest step forward in Internet history (ok, maybe that was never the case).

Time and Technology stop for no man, and it certainly does not stop for the applications we build. So what can we do to keep them fresh and healthy? It’s not so different from the additional exercise, better diet, and regular checkups that we do for ourselves. In the case of technology, the key is to keep up on blogs, product releases, and to continue to use the application so you can understand its needs.

Microsoft released .NET 4.5 on August 15, 2012, and I was pleased to have a few minutes to install Visual Studio 2012 with .NET 4.5, and give webTRAIN, our Web Marketing Platform, an upgrade.

webTRAIN was built back in 2007 as a .NET 2.0 website using Visual Studio 2005. Since that time, we have upgraded it to .NET 3.5 and have been using Visual Studio 2008 to code it. I really have been looking forward to upgrading to .NET 4.0, but I wanted to wait until we had new servers with IIS 7 installed.

We made the move to a new 4 server network with IIS 7 a few months back. With that, we were finally able to consider moving to .NET 4. I heard .NET 4.5 was around the bend, so it made sense to wait just a bit longer.

The actual process of moving into Visual Studio 2012 and .NET 4.5 was not as painful as I thought it would be. We have run into two hiccups so far in our testing.

1) .NET 4.5 handles request validation differently that .NET 3.5 and .NET 4.0. This came up specifically when trying to pass HTML from a Tiny MCE editor to our model. We found the answer in this whitepaper. The portion that affected us was “Support for unvalidated requests’”, which I have copied below:


To allow this, ASP.NET 4.5 now supports unvalidated access to request data. ASP.NET 4.5 includes a newUnvalidated collection property in the HttpRequest class. This collection provides access to all of the common values of request data, like Form, QueryString, Cookies, and Url.

Using the forum example, to be able to read unvalidated request data, you first need to configure the application to use the new request validation mode:

<httpRuntime requestValidationMode="4.5" ... />

You can then use the HttpRequest.Unvalidated property to read the unvalidated form value:

var s = context.Request.Unvalidated.Form["forum_post"];

Security Note: Use unvalidated request data with care! ASP.NET 4.5 added the unvalidated request properties and collections to make it easier for you to access very specific unvalidated request data. However, you must still perform custom validation on the raw request data to ensure that dangerous text is not rendered to users.



2) After updating our development servers to .NET 4.5, webTRAIN seemed fine and dandy. However, we found that it caused an issue with an MVC app that used automatic build and deploy via Team City on our development server. It built the code against .NET 4.5 assemblies and when we deployed it live, where .NET 4.5 is not yet installed, it ran into an error.

The error was:

Could not load type ‘System.Runtime.CompilerServices.ExtensionAttribute’ from assembly ‘mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089’.

We ended up having to retrieve mscorlib from C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.0 and building it directly into our application. It required a manual change to the programs’ XML file to include:

<Reference Include=”mscorlib” />

<Reference Include=”System.Core” />

There’s still lots more testing to do to make sure webTRAIN will play nicely with the new updates, but it’s great to know that we can begin to include Strongly Typed Datasets, Model Binding, HTML 5 snippets, and all the other great .NET 4.5 upgrades into our new features. webTRAIN is feeling younger already!

Have you had luck upgrading to .NET 4.5?

Aaron Brander is the VP of Technology for MINDSCAPE at Hanon McKendry.