RickardPettersson / swish-api-csharp

Swish For Merchant API Client .Net Standard Library
MIT License
29 stars 14 forks source link

client.SendAsync hangs when using the library from Blazor server page #14

Closed shogedal closed 2 years ago

shogedal commented 2 years ago

Do you suppose it is because the HttpClient is not created from an HttpClientFactory?

RickardPettersson commented 2 years ago

no idea, never used Blazor.

shogedal commented 2 years ago

It seems like it is the same as ASP.Net Core. Although I am still working with IIS Express (built into Visual Studio 2022) I got a clue from https://stackoverflow.com/questions/33014188/httpclient-never-sends-request-on-iis to add this just before the PostAsync: httpRequestMessage.Headers.Add("host", httpRequestMessage.RequestUri.Host); and it works like a charm.

RickardPettersson commented 2 years ago

I adding it to the new version i working on so its maybe works better.

RickardPettersson commented 2 years ago

I have now updated the code and the NuGet package version 2.0 is on the way, Microsoft doing stuff with the package before it come available public but the code is in this repository from now. The latest code has split the different functions to different classes so example eCommerceClient is the new C# class to use for e-commerce functionality and all of the clients has now the host header set before the PostAsync function being called.