I want to have different views in different directories (NOT AREAS!) so that when the URL contains a certain string , the viewEngine will result serving the another view (same name) from a different directory.
The Code is here:
public class CheckinViewEngine : WebFormViewEngine
{
public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)
{
ViewEngineResult result;
var routData = controllerContext.RequestContext.RouteData.Values;
if (controllerContext.RequestContext.HttpContext.Request.Path.ToUpper().Contains("UP"))
{
result= base.FindView(controllerContext, "Home/Up/" + viewName, masterName, useCache);
}
else
{
result= base.FindView(controllerContext, viewName, masterName, useCache);
}
return result;
}
}
In this case I check that the URL contains "UP".
In Global.asax I've added:
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new CheckinViewEngine ());
My problems are so: the ViewEngineResult.View is null and also, upon any request I get infinite loop request for this method.
Any Idea?