中间件中如果想用Service服务,不能用注入,需要这样写:
using (var serviceCope = httpContext.RequestServices.CreateScope())
{
    ISysSettingService? _sysSettingService = serviceCope.ServiceProvider.GetService<ISysSettingService>();
    if (_sysSettingService != null){...}
}

 来源:https://www.cnblogs.com/shipengfei/p/16092063.html

posted on 2024-02-05 17:11  邢帅杰  阅读(188)  评论(0编辑  收藏  举报