Closed brobichaud closed 6 years ago
You can register your class with the container. And in its constructor, take a IHttpContextAccessor
.
Keep in mind the framework doesn't register it by default so you'd need to call:
services.AddHttpContextAccessor()
which is a helper method for:
AddSingleton<IHttpContextAccessor,HttpContextAccessor>()
Thanks @bruno-garcia. I was actually able to make it work simply by adding IHttpContextAccessor accessor to my class ctor, no other changes were needed.
Cool. That means another library you use already had it registered.
I'm implementing my own IBasicCredentialVerifier and need access to some of the request details. How would I go about injecting the HttpRequest object into my IBasicCredentialVerifier:Authenticate method?