InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor' while attempting to activate 'DInjectionProvider.WholeInjection'.

Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, bool throwIfCallSiteNotFound)

As of .NET Core 2.1 there is an extension method that has been added to correctly register an IHttpContextAccessor as a singleton. See Add helper to register IHttpContextAccessor #947. Simply add as follows in your ConfigureServices() method:

services.AddHttpContextAccessor();

相关文章:

  • 2021-08-16
  • 2021-05-10
  • 2021-04-22
  • 2021-12-31
  • 2021-07-10
  • 2021-10-09
猜你喜欢
  • 2022-01-06
  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
  • 2021-09-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案