I am trying to make a call from my WPF project to an API that I created in ASP.NET Core. When the call is made to the Web API end point, it is returning an error: Unable to connect to the remote server with the inner error being SocketException: No connection could be made because the target machine actively refused it.
This is all being done on the localhost.
The code that is creating this call is(the second line throws the exception):
string RequestUri = "api/Class/GetEverythingDue";
HttpResponseMessage response = await myClient.GetAsync(RequestUri);
With myClient being an HttpClient that I configured like so:
this.myClient = new HttpClient();
myClient.BaseAddress = new Uri("http://localhost:56030/");
myClient.DefaultRequestHeaders.Accept.Clear();
myClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
I realize there are several questions with similar problems, I just haven't seen any yet that have to do with .NET Core. I just wanted to make sure that the problem wasn't due to using WPF and .NET Core together and it was due to them being incompatible.
Any help is appreciated.
Thanks
Aucun commentaire:
Enregistrer un commentaire