简体   繁体   中英

How to add Razor view in MVC 3 after upgrade from MVC 2 hardcoded?

I have a MVC 2 project which I am trying to upgrade to MVC 3 but using tool I got the error that SLN file are invalid even it's fine and work for me.

so I Upgrade them manually, It means

In sln file change the keys and change the config file in views and in main directory and remove the MVC 2 dll and add the MVC 3 dll.

now my project convert to MVC 3 but a little problem I fond that when I am trying to add a views I am unable to find the option, It's only show me aspx in the New Window. I need MVC 3 razor based views & layout.

how I can get razor in the menu (add new View option)

You have to do a bit more with the project file. check out this post, similar problem: ASP.NET MVC3, Enable Razor


to paraphrase:

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.


see if that fixes your issue.

Personally I'd create a new MVC3 project and copy over the controllers and views and work on them as I need to.

Remember though if you create a new razor view you will need to remove your existing aspx or ascx view as there are checked for first before cshtml (razor).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM