Hi,
after upgrading from 0.5.1 to 0.6.0, no Http-Calls via Flurl are possible any more:
WASM: [Flurl.Http.FlurlHttpException] Call failed. Cannot invoke method because it was wiped. See stack trace for details.
What to do?
@DNF-SaS that would happen if Flurl would try to use HttpClientHandler. If you got Flurl to work in webassembly, it means that Flurl is still trying to do something with HttpClientHandler
@Suchiman What does that mean? Flurl is working fine with 0.5.1
@DNF-SaS it means that Flurl is new'ing up HttpClientHandler somewhere even if that's all it's doing.
Flurl gets a HttpClientFactory, which passes Blazor's HttpClient into Flurl for use. This approach has worked fine for all Blazor-Versions (including 0.5.1). Flurl has not been changed. So why does it not work with 0.6 any more?
@DNF-SaS because the HttpClientHandler is now being wiped (removed) aggressively due to https://github.com/aspnet/Blazor/pull/1382 for considerable space savings.
@Suchiman Do you know how to prevent wiping for the HttpClientHandler in this case? It's seems too aggressive.
@DNF-SaS it's not too aggressive, it's just Flurl having a dependency on HttpClientHandler. I'm afraid there's no way to disable this (the assemblies get wiped when producing the nuget packages)
@Suchiman Flurl has a dependency on HttpClientHandler in the sense the it targets .NET Standard and therefore assumes that class is available and functional. .NET Standard is supposed to guarantee that it's safe to make that assumption. I don't really know the background on this so correct me if I'm wrong, but Blazor purports to support .NET Core 2.1, but in practical terms it really doesn't, does it? It appears that this wiping process removes platform implementations and replaces them with runtime exceptions so that it can still can still be consumed in .NET Core 2.1 projects. I could see this causing problems with more libraries that just Flurl.
Is there an implementation of HttpMessageHandler that Blazor does not wipe? Armed with that I can provide a way to work around this with Flurl. Thanks.
@tmenier HttpClientHandler is not functional in the browser as it relies on native code or sockets. In Blazor, there's a BrowserHttpMessageHandler that powers HttpClient. Since 0.6, this message handler is also used by default if you create a standard HttpClient as in new HttpClient(), doing new HttpClient(new HttpClientHandler()) is unsupported though (although new HttpClient(new BrowserMessageHandler()) would work).
The thing that is new in 0.6 is, is that HttpClientHandler which isn't functional anyway in wasm, is being removed in 0.6 which saves ~500KB on the output size, so just trying to construct it should already be an error (previously this would work up until the point HttpClientHandler.SendAsync is being invoked).
In Theory though, it should be possible to work with the mono guys to have HttpClientHandler work on WebAssembly instead of using an alternative HttpMessageHandler but that's where we are right now.
@Suchiman Perfect. I just spotted BrowserHttpMessageHandler myself. Flurl has a hook to easily swap that in for HttpClientHandler globally, so that should work. Thanks!
In Theory though, it should be possible to work with the mono guys to have HttpClientHandler work on WebAssembly instead of using an alternative HttpMessageHandler but that's where we are right now.
That is actually what's happening. This is being worked on inside Mono by @kjpou1. We're not ready to take that Mono update in time for 0.6.0 but should be ready in time for 0.7.0. So from 0.7.0, assuming it doesn't bloat the app size significantly, we'd aim to deprecate BrowserHttpMessageHandler and use the default BCL HttpMessageHandler.
Since there's no further action inside Blazor right now, I'll close this.
Thanks for the investigations and answers, everyone who posted above!
Solution for this issue is on Stack Overflow here: https://stackoverflow.com/questions/52522004/blazor-0-6-0-wipes-flurl-compatibility/52526415#52526415
Cannot invoke method because it was wiped. See stack trace for details.

I'm getting this error in the case of blazor but it works perfectly in the case of Razor component.
I'm have generated client using NSwag
@iAmBipinPaul look here: https://stackoverflow.com/questions/52522004/blazor-0-6-0-wipes-flurl-compatibility
Most helpful comment
That is actually what's happening. This is being worked on inside Mono by @kjpou1. We're not ready to take that Mono update in time for 0.6.0 but should be ready in time for 0.7.0. So from 0.7.0, assuming it doesn't bloat the app size significantly, we'd aim to deprecate
BrowserHttpMessageHandlerand use the default BCLHttpMessageHandler.Since there's no further action inside Blazor right now, I'll close this.
Thanks for the investigations and answers, everyone who posted above!