Authentication problem in SignalR

Hi, im making a chat application with .net core and signalr. I use token auth. when im already authenticated but the message does not show it in this. [Authorize] public override async Task OnConnectedAsync() { await Clients.All.SendAsync("ReceiveSystemMessage", $"{Context.UserIdentifier} joined."); await base.OnConnectedAsync(); } [Authorize] public override async Task OnDisconnectedAsync(Exception exception) { await base.OnDisconnectedAsync(exception); } connection starts and only shows joined. This is my program.cs // Add Authentication builder.Services.AddAuthentication().AddBearerToken(IdentityConstants.BearerScheme); builder.Services.AddAuthorizationBuilder(); builder.Services.AddIdentityCore<User>() .AddEntityFrameworkStores<Context>() .AddApiEndpoints(); var app = builder.Build(); app.UseCors(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } app.UseHttpsRedirection(); app.UseAuthentication(); app.UseAuthorization(); app.MapIdentityApi<User>(); app.MapControllers(); app.MapHub<ChatHub>("/chathub"); app.Run(); Please help
6 Replies
oke
oke4mo ago
$paste
MODiX
MODiX4mo ago
If your code is too long, you can post to https://paste.mod.gg/, save, and copy the link into chat for others to see your shared code!
oke
oke4mo ago
$code
MODiX
MODiX4mo ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat For longer snippets, use: https://paste.mod.gg/
YureshTharushika
this is program.cs file: https://paste.mod.gg/lkqeymkcboms/0
BlazeBin - lkqeymkcboms
A tool for sharing your source code with the world!
YureshTharushika
BlazeBin - czatefeytbmm
A tool for sharing your source code with the world!
Want results from more Discord servers?
Add your server