How to make razor the default view engine in existing project

6.5k views Asked by At

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

There are 3 answers

1
marcind On BEST ANSWER

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?

0
jgauffin On

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());
0
Gio On

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.