/// <summary> /// This constructor expects each area to be organized using feature folder convention. /// It clears out all view locations so that views of the main project do not serve as a default for area views /// </summary> /// <param name="eFolders">You can pass multiple flags if some of your areas are organized conventionally and some are organized using feature format</param> public FeatureFolderViewEngine(AreaFolderOrganization eFolders) { // {0} ActionName; {1} ControllerName; {2} AreaName var list = new List<string>(); if (eFolders.HasFlag(AreaFolderOrganization.ConventionalFolders)) { // If conventional support is needed, add the current area folders list.AddRange(this.AreaViewLocationFormats.Where(p => p.EndsWith(".cshtml"))); } if (eFolders.HasFlag(AreaFolderOrganization.FeatureFolders)) { var locs = new[] { "~/Areas/{2}/{1}/{0}.cshtml", "~/Areas/{2}/SharedViews/{0}.cshtml", // Replacement for "Views/Shared" }; list.AddRange(locs); } AreaViewLocationFormats = AreaMasterLocationFormats = AreaPartialViewLocationFormats = list.ToArray(); // Does not look for views within the main project. ViewLocationFormats = MasterLocationFormats = PartialViewLocationFormats = new string[0]; _isAreaEngine = true; FileExtensions = new[] { "cshtml" }; }
/// <summary> /// This constructor expects each area to be organized using feature folder convention. /// It clears out all view locations so that views of the main project do not serve as a default for area views /// </summary> /// <param name="eFolders">You can pass multiple flags if some of your areas are organized conventionally and some are organized using feature format</param> public FeatureFolderViewEngine(AreaFolderOrganization eFolders) { // {0} ActionName; {1} ControllerName; {2} AreaName var list = new List <string>(); if (eFolders.HasFlag(AreaFolderOrganization.ConventionalFolders)) { // If conventional support is needed, add the current area folders list.AddRange(this.AreaViewLocationFormats.Where(p => p.EndsWith(".cshtml"))); } if (eFolders.HasFlag(AreaFolderOrganization.FeatureFolders)) { var locs = new[] { "~/Areas/{2}/{1}/{0}.cshtml", "~/Areas/{2}/SharedViews/{0}.cshtml", // Replacement for "Views/Shared" }; list.AddRange(locs); } AreaViewLocationFormats = AreaMasterLocationFormats = AreaPartialViewLocationFormats = list.ToArray(); // Does not look for views within the main project. ViewLocationFormats = MasterLocationFormats = PartialViewLocationFormats = new string[0]; _isAreaEngine = true; FileExtensions = new[] { "cshtml" }; }