public ViewEngineResult ResolveView(string viewName, string layout, ViewResolutionContext resolutionContext) { var failedResults = new List<ViewEngineResult>(); foreach(var viewEngine in ViewEngines) { var result = viewEngine.ResolveView(viewName, layout, resolutionContext); if (result.Successful) return result; else failedResults.Add(result); } return new ViewEngineResult(failedResults.SelectMany(res => res.SearchedLocations)); }
public virtual ViewEngineResult ResolveView(string viewName, string layout, ViewResolutionContext resolutionContext) { string[] viewLocationsSearched; string[] masterLocationsSearched; string areaName = resolutionContext.AreaName; string controllerName = resolutionContext.ControllerName; string viewPath = GetPath(ViewLocationFormats, AreaViewLocationFormats, "ViewLocationFormats", viewName, controllerName, areaName, out viewLocationsSearched); string layoutPath = GetPath(LayoutLocationFormats, AreaLayoutLocationFormats, "MasterLocationFormats", layout, controllerName, areaName, out masterLocationsSearched); if (String.IsNullOrEmpty(viewPath) || (String.IsNullOrEmpty(layoutPath) && !String.IsNullOrEmpty(layout))) { return new ViewEngineResult(viewLocationsSearched.Union(masterLocationsSearched)); } return new ViewEngineResult(CreateView(viewPath, layoutPath), this); }