You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When SendAsync is called on HttpClient, the HttpResponseMessage.RequestMessage is null when the HttpClient is in Blazor WASM, but not null (and equal to the original HttpRequestMessage) on NET Core.
In NET Core, we do:
HttpClient httpclient = new HttpClient();
HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, "https://www.bing.com");
HttpResponseMessage responseMessage = await httpclient.SendAsync(
requestMessage,
HttpCompletionOption.ResponseHeadersRead);
In Blazor WASM, we have the HttpClient registered as:
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
Describe the bug
When
SendAsync
is called onHttpClient
, theHttpResponseMessage.RequestMessage
is null when theHttpClient
is in Blazor WASM, but not null (and equal to the original HttpRequestMessage) on NET Core.In NET Core, we do:
In Blazor WASM, we have the
HttpClient
registered as:And in a Blazor page:
To Reproduce
Sample code in this repo: https://github.com/ealsur/httpclientwasm
Running the Console app, the output is:
https://github.com/ealsur/httpclientwasm/blob/master/ConsoleApp/Program.cs#L19
Running the Blazor WASM app and browsing to Fetch Data, shows the output in the Browser Console:
https://github.com/ealsur/httpclientwasm/blob/master/Blazor/Pages/FetchData.razor#L48
The text was updated successfully, but these errors were encountered: