I would like to use one httpclient to many method in class. Below is the simplified code:
public class test{
private readonly HttpClient _httpClient;
public Test(){
_httpClient = new HttpClient();
}
public void method1(){
using (_httpClient){
//...
}
}
public void method2(){
using (_httpClient){
//...
}
}
public void method3(){
using (_httpClient){
//...
}
}
}
Then it calls the method data:
public async static void TestHttpClient()
{
Test test1 = new Test();
test1.Method1();
test1.Method2();
test1.Method3();
}
Method 1 is working. When calling the second one I get the message: "You cannot access a deleted object."
Thanks for helps.
Regards
IHttpClientFactory.