3

I have an ASP.NET MVC 2 web site that I've already upgraded to MVC 3. I'm not finding it very easy for new Razor views to coexist with my older ASPX views. I've found some articles, but I've failed at all of their suggestions and it seems not many people have been successful at doing this.

Has Microsoft made anything to make it easier to add Razor support to an upgraded MVC 2 app?

JustinStolle
  • 4,182
  • 3
  • 37
  • 48
aspm
  • 99
  • 1
  • 3
  • 1
    Here's basically the same question: http://stackoverflow.com/questions/4644698/how-to-download-razor-view-engine/4652007 – Buildstarted Jan 12 '11 at 22:33
  • Are you asking about having Razor views in an MVC 2 project or are you having issues with Razor in an MVC 3 project? – marcind Jan 12 '11 at 22:59
  • i have a MVC2 project that i upgraded to MVC3. now i have a bunch of views that are not razor, but i want to begin to add razor views since i don't want to rewrite all the views into razor. hopefully the links above help me cuz so far i haven't found anuythign that has. – aspm Jan 12 '11 at 23:02
  • Ah, sorry, misunderstood what you were asking :) – Buildstarted Jan 13 '11 at 00:09

3 Answers3

0

I haven't done this myself, however in this post by Scott Guthrie, there's this screenshot:

Razor View Engine

Given that this setting exists on the View, it suggests that you can have multiple views using different view engines. This means you should be able to run your existing code as normal, but add new views using Razor.

You can always test this out with a new project, and try adding two views - one using ASPX and one using Razor. If it all works, try diffing the test project to your existing one (specifically things like project and .config files).

Danny Tuppeny
  • 40,147
  • 24
  • 151
  • 275
0

You can use this tool from Telerik: https://github.com/telerik/razor-converter to convert your ASPX to CSHTML

Achinth Gurkhi
  • 2,136
  • 4
  • 24
  • 45
0

The following steps worked for me.

  1. Create another Temporary project based on MVC 3 Razor support by default
  2. Compare the references, web.config (main one and one under views folder) in the Temporary project with my own project. Here I found references to System.Web.Helpers & System.Web.Webpages. Similar mentions exist in the web.config files also. Just copy those sections from the temporary project to your project.
  3. Copy the _ViewStart.cshtml file from temporary project to your project (under Views folder)
  4. Copy the _Layout.cshtml file from temporary project to your project (under Views\Shared folder)
  5. Also check inside _Layout.cshtml. It may be referencing other partial views, jquery (js file) etc. Make sure they all exist in your own project.
  6. That's it. Compile and all should be set right.
Gautam Jain
  • 6,789
  • 10
  • 48
  • 67