services.AddHttpClient("Name", client =>
{
client.DefaultRequestHeaders.AcceptLanguage.Clear();
client.BaseAddress = new Uri('BaseUrl');
})
.AddAuthenticationHandler(config).Services
.AddScoped(sp => sp.GetRequiredService<IHttpClientFactory>()
.CreateClient('ClientName'));
public partial class StudentClient : IStudentClient
{
private System.Net.Http.HttpClient _httpClient;
public UsersClient(System.Net.Http.HttpClient httpClient)
{
_httpClient = httpClient;
}
}
Right now I have given a code to use HttpClient for accessing services. Now the problem is I have multiple base URLs to call different services and I need to configure that as well. so how can I implement it?