Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.net 8 blazor wasm PlatformNotSupportedException #823

Open
codegurney opened this issue May 10, 2024 · 7 comments
Open

.net 8 blazor wasm PlatformNotSupportedException #823

codegurney opened this issue May 10, 2024 · 7 comments

Comments

@codegurney
Copy link

Using the code from the docs on a Blazor WASM application:
`services.AddSingleton(sp => new FlurlClientCache()
.Add("MyCli", "https://some-api.com"));

public MyService(IFlurlClientCache clients) {
_flurlCli = clients.Get("MyCli");`

causes a PlatformNotSupportedException. Looking at the stack trace, it looks like it is related to UseCookies.

@codegurney codegurney added the bug label May 10, 2024
@codegurney codegurney changed the title .net 8 blazorr wasm PlatformNotSupportedException .net 8 blazor wasm PlatformNotSupportedException May 10, 2024
@tmenier
Copy link
Owner

tmenier commented May 15, 2024

What version of Flurl.Http?

@eric-gurney-omac
Copy link

4.0.2

@eric-gurney-omac
Copy link

Looking into this a little more, it is a handled exception, but Rider is still breaking when this exception is thrown. Would it be possible to check for WASM before setting the UseCookies property on HttpClientHandler?

@tmenier
Copy link
Owner

tmenier commented May 23, 2024

That try/catch is meant to be sort of a future-proof catch-all so Flurl doesn't need to sniff for specific platforms. I'll make a note to look at it, there's some sniffing going on in other areas so this isn't a hard rule. Can you exclude PlatformNotSupportedException from exceptions that Rider breaks on? You can in VS but I'm less familiar with Rider.

@tmenier
Copy link
Owner

tmenier commented May 23, 2024

And along the lines of future-proofing, if some future version of WASM adds support for UseCookies, this could cause problems. So it's kind of doubtful I'll make a change here, but I will still take a look at it.

@codegurney
Copy link
Author

Probably. For now, at least in development, I have forked the repo and added...
#if NETCOREAPP if (!OperatingSystem.IsBrowser()) #endif
before the call to
handler.UseCookies = false;
in FlurlClientFactory.cs

@codegurney
Copy link
Author

maybe add configuration option to toggle whether or not to use cookies?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

No branches or pull requests

3 participants