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)
Razor is a markup syntax that lets you embed server-based code into web pages using C# and VB.Net. It is not a programming language. It is a server side markup language. Razor has no ties to ASP.NET MVC because Razor is a general-purpose templating engine.
A Razor Page is almost the same as ASP.NET MVC's view component. It has basically the syntax and functionality same as MVC. The basic difference between Razor pages and MVC is that the model and controller code is also added within the Razor Page itself. You do not need to add code separately.
The namespace for Razor Engine is System. The Razor file extension is "cshtml" for the C# language. By default, Razor View Engine encodes html tags or scripts before it's being rendered to view that avoids Cross-Site Scripting attacks.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With