4

I am trying to include a partial view in a view that is located in a different folder. So I have the following view:

/_mvc/Views/Home/Index.cshtml

It has the following line of code:

@Html.Partial("~/_mvc/Views/Subject/_QuickSearch.cshtml", Model.QuickSearchModel);

This is not working. I keep getting the following error:

The partial view '~/_mvc/Views/Subject/_QuickSearch' was not found or no view 
engine supports the searched locations. The following locations were searched:
~/_mvc/Views/Subject/_QuickSearch

Am I missing something obvious? I should point out that I have modified the routing for my application to place all MVC code in the _mvc folder. This is not a mistake. The application is in the process of being converted from WebForms to MVC and I wanted all the MVC stuff under one folder.

rene
  • 41,474
  • 78
  • 114
  • 152
Leslie Hanks
  • 2,347
  • 3
  • 31
  • 42
  • I'm not sure why you would use the _mvc folder to start with, webforms wouldn't be using the Views folder to begin with? – Chris Marisic Aug 25 '11 at 21:52
  • I am using _mvc because I am converting an existing webforms application to use mvc, but I want to isolate all the mvc code so that once the webforms code has been replaced, I can easily reconfigure the app to a standard form. – Leslie Hanks Oct 17 '11 at 05:37

1 Answers1

6

If the root of your application is the _mvc/ folder, then all you should need to do is:

@Html.Partial("~/Views/Subject/_QuickSearch.cshtml", Model.QuickSearchModel);

In your case, ~ already points to mvc_/.

Laurent
  • 3,798
  • 25
  • 22