ASP.NET MVC3, Enable Razor
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 开发者_JAVA百科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?
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.
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.
精彩评论