AddHttpMessageHandler
that contains constructor dependency/reference of typed HttpClient
solved at AddHttpClient
method
#64241
Unanswered
igorgomeslima
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to add
AddHttpMessageHandler
that uses aservice
resolved byAddHttpClient
, but when execution call the referencedMessageHandler
he throws an exception:Full code:
D.I
Well, only to be more "visual":
The idea of
DelegatingHandler
is to add authorization header on all requests made by thatHttpClient
(AddHttpClient<IMyApi, MyApi>
).The interface
IMyApi
implements/represents all methods of an Api (Auth & Others) and in this case,AuthHeaderHandler
class depends/usesIMyApi
atctor
to callGetAccessToken()
resolved by.AddHttpClient<IMyApi, MyApi>
method.Is
.AddHttpClient()
"lazy load" and only run this configuration at firsthttp request
? Why we can't: "OnlyAddHttpMessageHandler
after resolve D.I ofAddHttpClient
to avoid this exception"?Something similar here.
Any idea?
Beta Was this translation helpful? Give feedback.
All reactions