ASP.NET MVC3, Enable Razor

不羁岁月 提交于 2019-12-21 08:55:08

问题


I've upgraded an MVC2 project to MVC3 and now want to start using the Razor view engine but when I do Add->View it doesn't give me the option to choose the view engine.

I have updated the Web.config in my views folder and have compared with a new MVC 3 project but nothing is working.

Any ideas?


回答1:


I fixed this by changing the ProjectTypeGuids element in the .csproj file to the following:

<ProjectTypeGuids>{E53F8FEA-EAE0-44A6-8774-FFD645390401};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>

I can now choose either Razor or ASPX as my view engine.




回答2:


Do you get the option to create a razor view when you create a new MVC3 project?

The way I updated from 2 to 3 was: create a new MVC3 Project in the same solution; then do a straight copy of the controller, views and any helpers I needed from my MVC2 project.

Saves a lot of fiddling with csproj and web.config files.

By default the aspx and ascx pages will be found before the cshtml, so make sure you have removed these when you work on any razor views that are named the same and want to see if they are working.



来源:https://stackoverflow.com/questions/5157445/asp-net-mvc3-enable-razor

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