79218989

Date: 2024-11-23 22:55:15
Score: 1
Natty:
Report link

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);
    }
}
Reasons:
  • Blacklisted phrase (1): helped me a lot
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Hugo Oliveira Lamounier