ASP.NET Core 6.0: HttpClient not respecting BaseAddress in Scoped Services
I'm sure I'm missing something obvious here, but I'm working with an scenario with the `HttpClient` in my ASP.NET Core 6.0 application where it's not respecting the `BaseAddress` that I've set up when using it as a scoped service. I have defined my `HttpClient` in the `Startup.cs` like this: ```csharp public void ConfigureServices(IServiceCollection services) { services.AddHttpClient<MyService>(client => { client.BaseAddress = new Uri("https://api.example.com/"); }); } ``` Then, in my `MyService` class, I'm using it like this: ```csharp public class MyService { private readonly HttpClient _httpClient; public MyService(HttpClient httpClient) { _httpClient = httpClient; } public async Task<string> GetDataAsync(string endpoint) { var response = await _httpClient.GetAsync(endpoint); response.EnsureSuccessStatusCode(); return await response.Content.ReadAsStringAsync(); } } ``` When I try to call the `GetDataAsync` method with an endpoint like `/data`, I'm getting the following behavior: "The requested URL was not found on the server." This makes me believe that the `BaseAddress` isn't being applied, but when I debug, I can see that it's indeed set correctly in the `HttpClient` instance. I've also tried logging the final request URI using `_httpClient.BaseAddress` combined with the `endpoint` parameter, and I confirmed it constructs the expected URL as `https://api.example.com/data`, yet I still receive the 404 behavior. Could there be something I'm missing regarding the lifecycle of the `HttpClient` or how the base address is handled in scoped services? Is there a known scenario with the way `HttpClient` is set up in ASP.NET Core 6.0? Any insights would be appreciated!