Welcome to weblogs.com.pk Sign in | Join | Help


Recently received a change request for a solution that has not touched for a while, it was ASP.NET MVC3 deliverable and Visual Studio 2013 gave warning that it will has limited functionality. The project was started as original MVC in Visual Studio 2008 and was later updated to MVC2 in Visual Studio 2010. The project was later updated to MVC3 in Visual Studio 2012 but that update was just to keep the build system happy and not all the functionality was updated to MVC3. It even had ASPX based views (and not Razor) so I decided to upgrade the project to MVC4 to keep Visual Studio 2013 happy and went through the code updating the pieces bringing them par to the latest technology / framework version. In this post I will keep the notes / observations restricted to MVC3


Initial Upgrade

  • Visual Studio gives you a URL in the warning that has information on how to upgrade MVC3 project, you basically needs to update the Version= to Version= for System.Web.Mvc and Version= to Version= for System.Web.WebPages, System.Web.Helpers and System.Web.WebPages.Razor assemblies in your web.configs across the project. You also need to update the assembly bindings if you are using any third party library that’s compiled against MVC3 or earlier. Lastly, for the design / tools to work in Visual Studio, you need to replace {E53F8FEA-EAE0-44A6-8774-FFD645390401} with {E3E379DF-F4C6-4180-9B81-6769533ABE47} in ProjectTypeGuids element of CSPROJ file. http://www.asp.net/whitepapers/mvc4-release-notes has all the information you need!
  • The project was referencing these assemblies from GAC and had _bin_deployableAssemblies, I removed the references and deleted the deployable folder, added Microsoft.AspNet.Mvc NUGET package and it brought along Microsoft.AspNet.Razor, Microsoft.AspNet.WebPages and Microsoft.Web.Infrastructure packages, these assemblies get published automatically. I was supposed to keep framework settings to .NET v4; the server requirement.

Microsoft.Web.Infrastucture is interesting, it allows you to register Http Modules dynamically. David Ebbo had a nice blog post on it. He is also developer of WebActivatorEx, another very interesting NUGET package that you can use to have startup code without needing to call it in global.asax.cs. http://blogs.msdn.com/b/davidebb/archive/2010/10/11/light-up-your-nupacks-with-startup-code-and-webactivator.aspx has the details! I also went ahead and update other NUGET packages like jQuery and EntityFramework etc. We were using MvcFutures, for its strongly typed Html Action Helpers, luckily there’s NUGET package and RouteDebugger is also on NUGET as well. I was glad to had everything being referenced using consistently using NUGET.

Fixing Things

  • You can compile the views by setting, MvcBuildViews property in PROJ file to true; if its not working chances are project was created with initial MVC3 Tools. Phil Haack had a post how to fix it

The New Things

  • Ditch ASP.NET Web Development Server and instead use IIS Express
  • Ditch MicrosoftAjax.js and MicrosoftMvcAjax.js if you are still using them; they are no longer being updated and one can replace them with jQuery's $.post/$.get etc. You will need to replace AjaxHelpers extension methods (from System.Web.Mvc.Ajax namespace) accordingly with jQuery + Web Api
  • Razor was introduced in MVC3; our project had only ASPX based views and associated Master file; for the new breed of developers; we created Razor Master Layout and replaced the ASPX views which were involved in the Change Requests with CSHTML. We can have multiple type of views living together nicely
  • Brand Wilson had a nice series on Common Service Locator topic; you can evaluate it and introduce some Dependency Injection based goodness in the project
  • Entity Framework is now also NUGET and maintained separately; you can use POCOs and do some Code First based Models as well replacing EDMX / DBML based layer


In MVC2, for client side validation there were MicrosoftMvcValidation.js and MicrosoftMvcJQueryValidation.js Javascript libraries. These libraries can be replaced with jquery.validate.js (jQuery.Validation NUGET) and Microsoft's contributed jquery.validate.unobtrusive.js (Microsoft.jQuery.Unobtrusive.Validation NUGET) that uses jQuery based validation and is more modern approach. There's a nice comparison of the two on Stackoverflow!

Keep subscribed for MVC4 post!

Published Tuesday, October 27, 2015 2:23 PM by khurram
Filed under:


No Comments

New Comments to this post are disabled