Microsoft.AspNetCore.Mvc.Internal.ActionContext.GetNormalizedRouteValue() doesn't exist
I am implementing a custom Razor ViewEngine in .net Core 2.2.
MSDN states that the GetNormalizedRouteValue()
method exists within Microsoft.AspNetCore.Mvc.Internal for .Net Core 2.2, but it looks like it doesn't exist when I compile or inspect the assembly.
My Code
My code context where I am using use it is context.GetNormalizedRouteValue(AREA_KEY)
public class CustomViewEngine : IViewEngine
{
public ViewEngineResult FindView(ActionContext context, string viewName, bool isMainPage)
{
var controllerName = context.GetNormalizedRouteValue(CONTROLLER_KEY);
var areaName = context.GetNormalizedRouteValue(AREA_KEY);
var checkedLocations = new List<string>();
foreach (var location in _options.ViewLocationFormats)
{
var view = string.Format(location, viewName, controllerName);
if (File.Exists(view))
{
return ViewEngineResult.Found("Default", new CustomView(view, _customViewRendering));
}
checkedLocations.Add(view);
}
return ViewEngineResult.NotFound(viewName, checkedLocations);
}
Microsoft's API
When inspecting the Microsoft API, only the following method signatures appear to exist.
namespace Microsoft.AspNetCore.Mvc
{
public class ActionContext
{
public ActionContext();
public ActionContext(ActionContext actionContext);
public ActionContext(HttpContext httpContext, RouteData routeData, ActionDescriptor actionDescriptor);
public ActionContext(HttpContext httpContext, RouteData routeData, ActionDescriptor actionDescriptor, ModelStateDictionary modelState);
public ActionDescriptor ActionDescriptor { get; set; }
public HttpContext HttpContext { get; set; }
public ModelStateDictionary ModelState { get; }
public RouteData RouteData { get; set; }
}
}
I've checked MSDN's documentation and it indicates it should exist.
Error
'ActionContext' does not contain a definition for 'GetNormalizedRouteValue' and no accessible extension method 'GetNormalizedRouteValue' accepting a first argument of type 'ActionContext' could be found (are you missing a using directive or an assembly reference?)