How to make razor the default view engine in exist

2020-04-11 05:05发布

I upgraded an MVC 2 project to MVC 3. How can I set the default view engine to Razor on an existing project?

Edit: Sorry, I was rather unclear. I want to have Razor be the default type in the Add View dialog.

3条回答
Root(大扎)
2楼-- · 2020-04-11 05:08

The Add View dialog should default to a Razor selection in the view engine combobox if your project has at least one Razor file already or if it has no Aspx files (i.e. a project with no view files at all). Are you not seeing that behavior?

查看更多
干净又极端
3楼-- · 2020-04-11 05:12

There is a MVC3 Upgrade tool.

You can find the tool and the tutorial here: http://blogs.msdn.com/b/marcinon/archive/2011/01/13/mvc-3-project-upgrade-tool.aspx

When you create a new view you can choose the viewengine but i don't know possibilities to set razor like default.

查看更多
冷血范
4楼-- · 2020-04-11 05:21

Short answer:

Change in global.asax to use both webforms and razor:

ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());
ViewEngines.Engines.Add(new WebFormViewEngine());
查看更多
登录 后发表回答