首页 > 数据库技术 > 详细

Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor'

时间:2019-07-05 10:47:45      阅读:316      评论:0      收藏:0      [点我收藏+]

An unhandled exception occurred while processing the request.

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();

Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor'

原文:https://www.cnblogs.com/asd14828/p/11136814.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!