aleteia_learner
aleteia_learner
CC#
Created by aleteia_learner on 11/15/2022 in #help
✅ Best practice usage of HttpClient in .Net Framework 4.5
when using static instance of an httpclient, does that mean defaultrequestheaders cant be set again ? say if the auth token changes ?
9 replies
CC#
Created by aleteia_learner on 11/15/2022 in #help
✅ Best practice usage of HttpClient in .Net Framework 4.5
Currently have 3 classes which uses httpclient, and since each of these make a http request to 3 different baseurl's, does this mean that I will need 3 more static instances of httpclient ?
9 replies
CC#
Created by aleteia_learner on 11/15/2022 in #help
✅ Best practice usage of HttpClient in .Net Framework 4.5
like this right ?
private static readonly HttpClient client = new HttpClient();

public void MakeRestCall(string url){
var response = await client.GetAsync(uri);
}
private static readonly HttpClient client = new HttpClient();

public void MakeRestCall(string url){
var response = await client.GetAsync(uri);
}
9 replies