1

I am converting all of my views over to razor so I have created all new view files but I haven't deleted the aspx file (I just have them excluded from the project). When i go to test my site, it seems to try to look for and load the aspx files. When I delete these files, it works fine and defaults to my razor cshtml files.

My issues, I that i want to keep my aspx files around for a little bit (at least until i know everything is working).

Is there anyway to have an asp.net-mvc site look for razor view files first so i don't need to delete my aspx files to get this to work?

leora
  • 188,729
  • 360
  • 878
  • 1,366
  • 2
    Below SO link might help you. http://stackoverflow.com/q/4718209/287100 – pramodtech Nov 27 '11 at 13:19
  • I found [this question][1] which was helpful [1]: http://stackoverflow.com/questions/5118169/how-to-make-razor-the-default-view-engine-in-existing-project – leora Nov 27 '11 at 13:30

2 Answers2

3

The default order for view engines is Web Forms then Razor. Just change the order.

protected void Application_Start() {
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine()); ViewEngines.Engines.Add(new WebFormViewEngine()); // remaaining calls here // ... }

RickAndMSFT
  • 20,912
  • 8
  • 60
  • 78
0

I ran into the same issue when migrating a site from webforms to mvc. However I encountered the issue that MVC is greedy. My site would default to the mvc views and not the webforms. Ultimately what i did was create a new folder off the root of the webforms and set it as new application starting point. Then upload the mvc site into this folder. Then once i know all is well then i can take the webforms down. I found this to be best option.

Edit: Should've mentioned i tried the ignore routes thing to ignore .aspx pages - did not work for me at all.

Ashok Padmanabhan
  • 2,110
  • 1
  • 19
  • 36