Convert MVC 2 ASPX into MVC 4 Razor view engine

2019-04-22 21:36发布

问题:

I am currently working on MVC 2 with visual studio 2010 and view engine as ASPX kind of project.

So I have decided to move with Visual studio 2012 with MVC 4 and view engine as Razor.

So could I achieve above task.If so How ?

I would like to hear your experience for similar kind of situation.

Note : My project is a large one.

回答1:

Create a new MVC4 project in Visual Studio 2012 and add source files from your old solution to your new solution one at a time. Moving from MVC3 to MVC4 is easier with a new solution, I have to imagine that going from 2 -> 4 would be even more complex to try to upgrade in-place.

Conversion from ASPX to Razor should probably be done manually. Although there are converters out there (like this one or code like the accepted answer in this SO question), I personally wouldn't trust my application to pure automation.

Also, I would probably convert one at a time. In other words, convert from ASPX -> Razor or MVC2 -> MVC4 first and make sure everything works with your conversion. Then convert the other one so that if you run into any problems, you don't have to try to figure out whether it's the version upgrade or the syntax upgrade that caused your problem.