code4it-dev / blog-comments

https://www.code4it.dev/
1 stars 0 forks source link

blog/inject-httpcontext/ #52

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

How to access the HttpContext in .NET API | Code4IT

Code4IT - a blog for dotnet developers

https://code4it.dev/blog/inject-httpcontext/

an52x3648 commented 1 year ago

Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: [projectname].HttpContext.IHttpContextWarpper Lifetime: Scoped ImplementationType: [projectname].HttpContext.HttpContextWarpper': Unable to resolve service for type 'Microsoft.AspNetCore.Http.HttpContextAccessor' while attempting to activate '[projectname].HttpContext.HttpContextWarpper'.)'

bellons91 commented 1 year ago

That's weird. Have you added services.AddHttpContextAccessor();?