- ABP Framework version: v4.4.3
- UI type: Blazor Server
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): yes
We have a microservice project set up with blazor server front end project. We are trying to send notificatio on status change using signalR. We have created a hub inheriting from AbpHub and followed Microsofot's documentation to connect to hub from blazor server project. We are getting "Antiforgery token validation failed. The required antiforgery cookie ".AspNetCore.Antiforgery.RfvzpqGUp6I" is not present." when hubConnection.StartAsync() is invoked.
Do we have to add any configuration to make this work?
12 Answer(s)
-
0
Hi, It is a microservice template project with blazor server front end. We just created a hub in blazor server project and implemented hub connection from a razor page using "Microsoft.AspNetCore.SignalR.Client" package. Please find the signalR hub connection code below. "await hubConnection.StartAsync();" would invoke the signalR negotiate endpoint POST https://localhost:44314/signalr-hubs/applicationstatuschangenotification/negotiate?negotiateVersion=1 - 0
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
hi
Can you try to add csrf token to cookies and Headers?
https://github.com/abpframework/abp/blob/rel-4.4/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpBlazorClientHttpMessageHandler.cs#L75
https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.signalr.client.hubconnectionbuilderhttpextensions.withurl?view=aspnetcore-5.0#Microsoft_AspNetCore_SignalR_Client_HubConnectionBuilderHttpExtensions_WithUrl_Microsoft_AspNetCore_SignalR_Client_IHubConnectionBuilder_System_Uri_System_Action_Microsoft_AspNetCore_Http_Connections_Client_HttpConnectionOptions__
https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.connections.client.httpconnectionoptions?view=aspnetcore-5.0#properties
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi, I have already tried passing the RequestVerificationToken and the cookies to signalR connection. But it is giving the same error. ".AspNetCore.Antiforgery.RfvzpqGUp6I" is not present." This cookie ".AspNetCore.Antiforgery.RfvzpqGUp6I" doesn't exist in the browser cookies. Instead there is a similar cookie with name ".AspNetCore.Antiforgery.dHbfFikoQ1Y".
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi,
Cookies and request header are getting passed. We are using blazor server hosting model and not web assembly. We only have ".AspNetCore.Antiforgery.dHbfFikoQ1Y" cookie in the browser which is set from auth server. Not sure why it is trying to validate antiforgery token ".AspNetCore.Antiforgery.RfvzpqGUp6I" from blazor server.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi, The issue was due to the incorrect signalR url. The url didn't have the hub name in kebab-case. It started working after url changed to "/signalr-hubs/application-status-change-notification". But now getting issue with authorization. The token is getting passed in Authorization header, but signalR negotiation gives the following error.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
hi
Can you check these? https://docs.microsoft.com/en-us/aspnet/core/signalr/authn-and-authz?view=aspnetcore-6.0#built-in-jwt-authentication https://docs.microsoft.com/en-us/aspnet/core/signalr/authn-and-authz?view=aspnetcore-6.0#identity-server-jwt-authentication
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)



