✅ HttpClient Base Address Null in Blazor WASM
I have a Client class that was generated by NSwag Studio. I'm setting the client base URL in Program, but when I reference it in a component, the BaseAddress is null. The screenshot is using the HttpClientFactory, but even just injecting the Client directly, it's still null. What am I doing wrong here?
5 Replies
I have to head out, will check back later tonight. Thank you for any assistance you can offer
You’re adding the given http client to the “Client” class
So you’d be able to get it in the Client class, via dependency injection
However, if you want to get your clients via the IHttpClient you can add them with an identifier, and call CreateClient by passing its identifier as a string
At least that’s what I remember
If you want a default client, try adding without the generics.
Thank you for your help, I’ll see if I can get this working when I return to office tomorrow
Unknown User•5w ago
Message Not Public
Sign In & Join Server To View
Thank you both, I was able to get it to work with your advice. Appreciate it