我正在.NET 5 MVC 6中进行一些原型设计,并试图找出在哪里注册我的自定义剃刀视图引擎. MVC 6不再有global.asax文件来进行自定义对象的注册.它确实有一个startup.cs文件,我认为它是添加它的地
我目前有自定义剃刀视图引擎,看起来像
public class MyCustomerViewEngine : RazorViewEngine
{
public MyCustomerViewEngine()
{
//My custom view stuff
}
}
任何帮助将不胜感激.
在Startup.cs文件中转到ConfigureServices方法.
services.AddMvc(); // Replace this with following
services.AddMvc().Configure<MvcOptions>(options =>
{
options.ViewEngines.Add(new MyCustomerViewEngine ());
});
