What is the best way to migrate a MVC 2 project to

2020-06-09 04:14发布

What is the best way to migrate a MVC 2 project to MVC 3 using the Razor view engine?

5条回答
倾城 Initia
2楼-- · 2020-06-09 04:55

There are also links to upgrade tools on David Hayden's blog: http://davidhayden.com/blog/dave/archive/2011/01/05/ASPNETMVC3TutorialsIndex.aspx

查看更多
一纸荒年 Trace。
3楼-- · 2020-06-09 05:05

Details can be found in this post from ScottGu's blog (see the How to Upgrade Existing Projects section). I used the MVC 3 project upgrade tool and had only a few minor issues specific to my application after running it.

查看更多
欢心
4楼-- · 2020-06-09 05:09

There is no substitute for learning the Razor Syntax

Programming Razor

I think that some developers over-think razor and make it harder than it is. If you know HTML, JavaScript and C#, just learn some of the basic syntax like a code block

@model MyApp.Models.MyEntity

@{
    // this is a code block
    ViewBag.MyData = "i need to use a semicolon here";
}

<div class="myclass">
//This is inline razor/C# code that uses a 
//lambda expression to access a model property:
@Html.TextBoxFor(m => m.MyProperty)
</div>

The razor engine knows where the C# ends and the HTML begins, you just need to learn a few basic rules.

Edit: The point I am trying to make is that tools are not the only way to convert from MVC 2 to MVC 3 or 4 Razor. Conversion tools are not perfect. Knowledge of the Razor syntax can also be very helpful.

查看更多
祖国的老花朵
5楼-- · 2020-06-09 05:12

Telerik wrote a program to convert usual aspx views to razor

Have a look here : https://github.com/telerik/razor-converter

查看更多
对你真心纯属浪费
6楼-- · 2020-06-09 05:17

Do you need/want to move to Razor or just having MVC 3? You can still use your aspx pages with the WebFormViewEngine and MVC 3. This what I did on my side because we had quite a big app and more than just a few issues when migrating to MVC 3. So for a while we kept apsx pages and moved pages progressively to cshtml.

查看更多
登录 后发表回答