سؤال

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?

هل كانت مفيدة؟

المحلول

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 // ... }

نصائح أخرى

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top