You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
In MVC5 we created a custom view engine that had some customizations to allow for custom view location formats. In MVC we were able to change the strings for the patterns but still had to do additional work to to process them. In MVC6 everything looks to be private/readonly and we cannot do the same customization.
here is our MVC5 implementation:
using System.Web.Mvc;namespaceCustomViewEngine{//THIS VIEW ENGINE DOES NOT HANDLE AREAS.internalsealedclassCustomLookupViewEngine:RazorViewEngine{publicCustomLookupViewEngine(){ViewLocationFormats=new[]{"~/Views/%1/{1}/{0}.cshtml","~/Views/%1/Shared/{0}.cshtml","~/Views/Default/{1}/{0}.cshtml","~/Views/Default/Shared/{0}.cshtml",};MasterLocationFormats=new[]{"~/Views/%1/{1}/{0}.cshtml","~/Views/%1/Shared/{0}.cshtml","~/Views/Default/{1}/{0}.cshtml","~/Views/Default/Shared/{0}.cshtml",};PartialViewLocationFormats=new[]{"~/Views/%1/{1}/{0}.cshtml","~/Views/%1/Shared/{0}.cshtml","~/Views/Default/{1}/{0}.cshtml","~/Views/Default/Shared/{0}.cshtml",};}protectedoverride IView CreatePartialView(ControllerContextcontrollerContext,stringpartialPath){varsiteCode= GeValue(controllerContext,"siteCode");returnbase.CreatePartialView(controllerContext, partialPath.Replace("%1", siteCode));}protectedoverride IView CreateView(ControllerContextcontrollerContext,stringviewPath,stringmasterPath){varsiteCode= GeValue(controllerContext,"siteCode");returnbase.CreateView(controllerContext, viewPath.Replace("%1", siteCode), masterPath.Replace("%1", siteCode));}protectedoverrideboolFileExists(ControllerContextcontrollerContext,stringvirtualPath){varsiteCode= GeValue(controllerContext,"siteCode");returnbase.FileExists(controllerContext, virtualPath.Replace("%1", siteCode));}privatestaticstringGeValue(ControllerContextcontrollerContext,stringkey){varresult= ValueProviderFactories.Factories.GetValueProvider(controllerContext).GetValue(key);returnresult==null?null: result.AttemptedValue;}}}
The text was updated successfully, but these errors were encountered:
The changes made as part of ViewLocationExpanders largely covers the scenarios that you're trying to get to. ViewLocationFormats and AreaViewLocationFormats have also been made virtual in case you want to use the traditional route of subtyping the view engine although we recommend using expanders instead.
#1212 is meant for tracking some additional enhancement to the changes in #1039.
In MVC5 we created a custom view engine that had some customizations to allow for custom view location formats. In MVC we were able to change the strings for the patterns but still had to do additional work to to process them. In MVC6 everything looks to be private/readonly and we cannot do the same customization.
here is our MVC5 implementation:
The text was updated successfully, but these errors were encountered: