IT:AD:ASP.NET:MVC:Views:Partials
Xtra: Where does it Search
Not too bright – when it searches for a View, it looks here:
~/Views/BankWorkInstruction01/_BankWorkInstruction01DEView.aspx ~/Views/BankWorkInstruction01/_BankWorkInstruction01DEView.ascx ~/Views/Shared/_BankWorkInstruction01DEView.aspx ~/Views/Shared/_BankWorkInstruction01DEView.ascx ~/Views/BankWorkInstruction01/_BankWorkInstruction01DEView.cshtml ~/Views/BankWorkInstruction01/_BankWorkInstruction01DEView.vbhtml ~/Views/Shared/_BankWorkInstruction01DEView.cshtml ~/Views/Shared/_BankWorkInstruction01DEView.vbhtml
Modify Where it Searches
public class CustomViewEngine : WebFormViewEngine
{
public CustomViewEngine()
{
var viewLocations = new[] {
"~/Views/{1}/{0}.aspx",
"~/Views/{1}/{0}.ascx",
"~/Views/Shared/{0}.aspx",
"~/Views/Shared/{0}.ascx",
"~/AnotherPath/Views/{0}.ascx"
// etc
};
this.PartialViewLocationFormats = viewLocations;
this.ViewLocationFormats = viewLocations;
}
}
And then register it:
protected void Application_Start()
{
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new CustomViewEngine());
}
You can go further: [http://stackoverflow.com/questions/909794/how-to-change-default-view-location-scheme-in-asp-net-mvc](http://stackoverflow.com/questions/909794/how-to-change-default-view-location-scheme-in-asp-net-mvc)