I had exactly the same problem, I have a central Ajax controller that I use, in which I return different partial views from different folders / locations.
What you need to do is create a new ViewEngine derived from RazorViewEngine (I assume you are using Razor), and explicitly include the new locations in the constructor to search for scores in.
Alternatively, you can override the FindPartialView method. By default, the Shared folder and the folder from the current controller context are used for search.
Here is an example that shows how to override certain properties in a custom RazorViewEngine .
Update
You must specify the partial path in your PartialViewLocationFormats array as follows:
public class MyViewEngine : RazorViewEngine { public MyViewEngine() : base() { PartialViewLocationFormats = new string[] { "~/Area/{0}.cshtml"
Similarly, if you want to find partial in the controller inside the Area folder, you will need to add standard partial views to the AreaPartialViewLocationFormats array. I tested this and it works for me.
Remember to add a new RazorViewEngine to your Global.asax.cs , for example:
protected void Application_Start() {
Here's how you can use it in an example controller called "Home":
// File resides within '/Controllers/Home' public ActionResult Index() { var pt = ViewEngines.Engines.FindPartialView(ControllerContext, "Partial1"); return View(pt); }
I saved the part I'm looking for in the /Area/Partial1.cshtml path.
source share