问题
in beta6 we were able to plugin a custom viewengine like this:
services.AddMvc()
.AddViewOptions(options =>
{
options.ViewEngines.Clear();
options.ViewEngines.Add(typeof(MyCustomViewEngine));
});
this no longer works in beta7 and options.ViewEngines seems to have changed to an
IList<IViewEngine>
I don't understand how to plug one in without having to new it up and provide its dependencies
options.ViewEngines.Add(new it up here?);
How can I plug in my own custom viewengine in beta7?
回答1:
I figured it out, before calling
services.AddMvc()
I need to add my viewengine to DI
services.TryAddSingleton<IRazorViewEngine, MyCustomViewEngine>();
来源:https://stackoverflow.com/questions/32416007/how-to-plugin-custom-viewengine-in-mvc-6-beta7