C
C#5w ago
Camster

✅ 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?
No description
No description
5 Replies
Camster
CamsterOP5w ago
I have to head out, will check back later tonight. Thank you for any assistance you can offer
Gela
Gela5w ago
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.
Camster
CamsterOP5w ago
Thank you for your help, I’ll see if I can get this working when I return to office tomorrow
Unknown User
Unknown User5w ago
Message Not Public
Sign In & Join Server To View
Camster
CamsterOP4w ago
Thank you both, I was able to get it to work with your advice. Appreciate it
Want results from more Discord servers?
Add your server