如何在 MVC 6 beta7 中插入自定义视图引擎?
how to plugin custom viewengine in MVC 6 beta7?
在 beta6 中,我们能够像这样插入自定义视图引擎:
services.AddMvc()
.AddViewOptions(options =>
{
options.ViewEngines.Clear();
options.ViewEngines.Add(typeof(MyCustomViewEngine));
});
这在 beta7 中不再有效,options.ViewEngines 似乎已更改为
IList<IViewEngine>
我不明白如何在不更新它并提供其依赖项的情况下插入它
options.ViewEngines.Add(new it up here?);
如何在 beta7 中插入我自己的自定义视图引擎?
我想通了,然后打电话给
services.AddMvc()
我需要将我的视图引擎添加到 DI
services.TryAddSingleton<IRazorViewEngine, MyCustomViewEngine>();
在 beta6 中,我们能够像这样插入自定义视图引擎:
services.AddMvc()
.AddViewOptions(options =>
{
options.ViewEngines.Clear();
options.ViewEngines.Add(typeof(MyCustomViewEngine));
});
这在 beta7 中不再有效,options.ViewEngines 似乎已更改为
IList<IViewEngine>
我不明白如何在不更新它并提供其依赖项的情况下插入它
options.ViewEngines.Add(new it up here?);
如何在 beta7 中插入我自己的自定义视图引擎?
我想通了,然后打电话给
services.AddMvc()
我需要将我的视图引擎添加到 DI
services.TryAddSingleton<IRazorViewEngine, MyCustomViewEngine>();