How to make razor the default view engine in existing project

微笑、不失礼 提交于 2019-12-31 02:13:07

问题


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.


回答1:


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?




回答2:


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());



回答3:


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.



来源:https://stackoverflow.com/questions/5118169/how-to-make-razor-the-default-view-engine-in-existing-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!