【发布时间】:2023-03-26 00:37:01
【问题描述】:
我在 asp.net core 2.1 中有一个应用程序。我已经在 startup.cs 文件中注册/注入了 HttpContextAccessor,如下所示。
services.AddHttpContextAccessor();
我还为接口 IHttpContextAccessor 创建了一个对象,并在依赖注入类“GetScopedServicesTools”的构造函数中启动了该对象
public readonly IHttpContextAccessor HttpContextAccessor;
public GetScopedServicesTools(IHttpContextAccessor _httpContextAccessor)
{
HttpContextAccessor = _httpContextAccessor;
}
我为 DI 类“GetScopedServicesTools”创建了一个对象,但不确定需要将什么值传递给该类的构造函数。
private GetScopedServicesTools getScopedServices;
您能否帮我将什么值传递给“GetScopedServicesTools”类的构造函数。
【问题讨论】:
标签: c# asp.net-core asp.net-core-webapi nullreferenceexception