Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

To help our customers adopt ASP.NET MVC 2 I built an application that helps upgrade Visual Studio 2008 solutions that use ASP.NET MVC 1.0 to use ASP.NET MVC 2 Preview 2. This application is inspired by Scott Hanselman’s blog post on updating ASP.NET MVC projects to work in Visual Studio 2010 Beta 1.

image

Download

The app is a single executable: Download MvcAppConverter.zip (220 KB).

Usage

The only requirement for this tool is that you have .NET Framework 3.5 SP1 on the machine. You do not need to have Visual Studio or ASP.NET MVC installed (unless you want to open your project!). Even though the tool performs an automatic backup of your solution it is recommended that you perform a manual backup of the solution as well.

  • To convert an ASP.NET MVC 1.0 project built with Visual Studio 2008 to an ASP.NET MVC 2 project in Visual Studio 2008 perform these steps:
    • Launch the converter
    • Select the solution
    • Click the “Convert” button
  • To convert an ASP.NET MVC 1.0 project built with Visual Studio 2008 to an ASP.NET MVC 2 project in Visual Studio 2010:
    • Perform the above steps, then open the project in Visual Studio 2010 and it will perform the remaining conversion steps

What it can do

  • Open up ASP.NET MVC 1.0 projects from Visual Studio 2008 (no other versions of ASP.NET MVC or Visual Studio are supported)
  • Create a full backup of your solution’s folder
  • For every VB or C# project that has a reference to System.Web.Mvc.dll it will (this includes ASP.NET MVC web application projects as well as ASP.NET MVC test projects):
    • Update references to ASP.NET MVC 2
    • Add a reference to System.ComponentModel.DataAnnotations 3.5 (if not already present)
  • For every VB or C# ASP.NET MVC Web Application it will:
    • Change the project type to an ASP.NET MVC 2 project
    • Update the root ~/web.config references to ASP.NET MVC 2
    • Update the root ~/web.config to have a binding redirect from ASP.NET MVC 1.0 to ASP.NET MVC 2
    • Update the ~/Views/web.config references to ASP.NET MVC 2
    • Add or update the JavaScript files (add jQuery, add jQuery.Validate, add Microsoft AJAX, add/update Microsoft MVC AJAX, add Microsoft MVC Validation adapter)
  • Unknown project types or project types that have nothing to do with ASP.NET MVC will not be updated

What it can’t do

  • It cannot convert projects directly to Visual Studio 2010 or to .NET Framework 4.
  • It can have issues if your solution contains projects that are not located under the solution directory.
  • If you are using a source control system it might have problems overwriting files. It is recommended that before converting you check out all files from the source control system.
  • It cannot change code in the application that might need to be changed due to breaking changes between ASP.NET MVC 1.0 and ASP.NET MVC 2. Consult the readme for information on breaking changes.

Feedback, Please!

If you need to convert a project to ASP.NET MVC 2 please try out this application and hopefully you’re good to go. If you spot any bugs or features that don’t work leave a comment here and I will try to address these issues in an updated release.

Published Monday, October 19, 2009 12:38 PM by Eilon
Filed under: , ,

Comments

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Monday, October 19, 2009 4:50 PM by Chris Hardy (ChrisNTR)

Since Preview 2 is, as it implies, is a preview, I guess we'll continue to stick to using ASP.NET MVC 1 for production sites and purely use the converter to play around with ASP.NET MVC Preview 2 for the time being until a RC/RTM is out?

Nice work, looks like a handy tool!

# Twitter Trackbacks for Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2 - Eilon Lipton's Blog [asp.net] on Topsy.com

Pingback from  Twitter Trackbacks for                 Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2 - Eilon Lipton's Blog         [asp.net]        on Topsy.com

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Tuesday, October 20, 2009 4:59 PM by Gene

I tried a to do the migration (a large site from MVC 1.0 to 2.0 and from VS 2008 to VS 2010) myself, with disastrous results. I figured I was looking at spending a couple days fiddling with settings to get everything working again.

Your tool had it up and running in 5 minutes. No issues that I have found so far. Thank you so much!

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Tuesday, October 20, 2009 7:16 PM by Karl

Any chance on getting source code. This doesn't work as is for me. Its failing when looking for specific javascript files...I'm not crazy enough to use the default MVC structure, or leave in all the gunk js the default project uses.

# ASP.NET MVC Archived Blog Posts, Page 1

Wednesday, October 21, 2009 12:21 AM by ASP.NET MVC Archived Blog Posts, Page 1

Pingback from  ASP.NET MVC Archived Blog Posts, Page 1

# Lifting an ASP.NET MVC 1.0 project to Visual Studio 2010

Wednesday, October 21, 2009 3:41 AM by Johan's blog

Lifting an ASP.NET MVC 1.0 project to Visual Studio 2010

# Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2 - Eilon Lipton

Wednesday, October 21, 2009 2:34 PM by DotNetShoutout

Thank you for submitting this cool story - Trackback from DotNetShoutout

# Convertire un?applicazione da MVC 1 a MVC 2

Wednesday, October 21, 2009 3:29 PM by Il blog di ugo lattanzi

Convertire un?applicazione da MVC 1 a MVC 2

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Wednesday, October 21, 2009 11:34 PM by Donn Felker

Does this converter rely on project type guids? Reason I ask is because all of my MVC Projects do not contain the MVC project type guid (so users can download them from my blog after a presentation and not have to have MVC installed - I include the binaries in my d/l's).

Thanks!

Donn

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Thursday, October 22, 2009 7:23 AM by sorin

I get this error

Converting between two versions of Visual Studio is not supported

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Thursday, October 22, 2009 8:27 PM by I know my question is off subject

where can i find or is there a tool to generate standard CRUD method with LINQ TO SQL?

I dont want to reinvented the wheel!

Thanks..

# Convertendo aplica????es ASP.NET MVC 1 para ASP.NET MVC Preview 2 « Andr?? Borges Medeiros

Pingback from  Convertendo aplica????es ASP.NET MVC 1 para ASP.NET MVC Preview 2 « Andr?? Borges Medeiros

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Friday, October 23, 2009 5:33 PM by Jerrie Pelser

Great tool, thanks so much!

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Tuesday, October 27, 2009 11:23 AM by David Kujawski

Can you provide source code for this tool?  The tool doesn't work for our MVC v1 project because we have a spcialized folder structure (and the tool can't find some files).

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Tuesday, November 10, 2009 12:59 PM by goodbyeforms

Beautiful.  Thanks much.  And for those using Castle IoC, this signature has changed:

protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Saturday, November 14, 2009 8:23 AM by Hennie Gottenbos

The conversion worked OK and my project is now happily MVC2 however I do get an error about the web.config: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS. This web.config worked great for MVC1 so why is this now cropping up? I am using Visual Studio 2008. Thanks for any suggestions you can give me!

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Saturday, November 14, 2009 9:37 AM by Raj

Event after using the tool, I am not able to open the project. Visual Studio says "The project type is not supported by this installation".

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Sunday, November 15, 2009 4:57 PM by irobinson

This worked quite well for me on a project that was started from the CodeBetter Canvas project.

Although, it did fail until I added a "Scripts" folder in the "Web" project - so that it could add all of the JavaScript files to it.

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Monday, November 16, 2009 12:38 PM by matthewreily

Worked great for me!  Thank you

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Thursday, November 19, 2009 7:33 PM by Eilon

Karl

>>>>>>>>>> Any chance on getting source code. This doesn't work as is for me. Its failing when looking for specific javascript files...I'm not crazy enough to use the default MVC structure, or leave in all the gunk js the default project uses.

I am fixing this bug in the tool and will re-release it with support for ASP.NET MVC 2 Beta. I will see if I can get the source code published as well. We do plan to integrate most of this functionality into Visual Studio 2010 as well.

Thanks,

Eilon

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Thursday, November 19, 2009 7:36 PM by Eilon

Donn Felker

>>>>>>>>>> Does this converter rely on project type guids? Reason I ask is because all of my MVC Projects do not contain the MVC project type guid (so users can download them from my blog after a presentation and not have to have MVC installed - I include the binaries in my d/l's).

Hi Donn,

The converter relies on the project type GUID for certain parts of the functionality. Some features require that you use the MVC project type GUID, such as to decide whether to add the updated JavaScript files. Other features check whether the project is any kind of class library in order to update references of System.Web.Mvc.dll from 1.0.0.0 to 2.0.0.0. This is to support the scenario where you have a class library project that contains helpers or controllers that you want to convert.

A workaround is to temporarily add the project type GUID (which should be {603c0e0b-db56-11dc-be95-000d561079b0}), run the converter, and then remove the GUID (which will then be {f85e285d-a4e0-4152-9332-ab1d724d3325}).

Thanks,

Eilon

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Thursday, November 19, 2009 7:37 PM by Eilon

sorin

>>>>>>>> I get this error

>>>>>>>> Converting between two versions of Visual Studio is not supported

Hi sorin,

That error can occur if you try to convert a project that was build with Visual Studio 2010. Right now this tool only supports projects built with Visual Studio 2008.

Thanks,

Eilon

# Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2 Beta (updated!)

Monday, November 23, 2009 2:55 PM by Eilon Lipton's Blog

Thanks to the great feedback I’ve received on my ASP.NET MVC conversion tool for ASP.NET MVC 2 Preview

# Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2 Beta (updated!) | I love .NET!

Pingback from  Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2 Beta (updated!) | I love .NET!

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Wednesday, November 25, 2009 8:36 PM by mike o'neill

Your tool works well but you should set the reference to System.Web.Mvc to copy local= true. You need this if you want to deploy a mvc 2 project to Azure.

Leave a Comment

(required) 
(required) 
(optional)
(required)