I was having the same issue. Cookies were set when hitting the API directly, but not when hit from the Blazor WebAssembly app.
The accepted solution helped me a lot to fix the issue. I ended up creating a CredentialsHandler
to always set the BrowserRequestCredentials.Include
to my http requests, and added it to my HttpClient:
public class CredentialsHandler: DelegatingHandler
{
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
request.SetBrowserRequestCredentials(BrowserRequestCredentials.Include);
return base.SendAsync(request, cancellationToken);
}
}