how to solve the problem no connection could be made because the target machine actively refused C# HttpClient

Viewed 53

I try to run this code in asp.net core

 HttpClient client = new HttpClient();
 client.Timeout = TimeSpan.FromMinutes(30);
 client.BaseAddress = new Uri("http://192.168.10.25/");
HttpResponseMessage getTokenresponse = client.GetAsync("api/getToken/getitss?username=Ahmad&password=ahmad@123").Result;
 var a = getTokenresponse.Content.ReadAsStringAsync();
 string token = a.Result.Replace(@"""", "").Replace(@"\", "");

when I run the code and debug it the code makes me an error like this:
no connection could be made because the target machine actively refused, in postman, it work for me and give me the token but when I run it in c# code it give me an error. can anyone help me thanks

0 Answers
Related