C
C#5mo ago
drei3837

✅ SignalR in a background service

I created a worker service project , installed Microsoft.Asp.netcore.SignalR.Client package but i cant add it in the program.cs file. Error: CS1061 ISericeCollection does not contain the definition for addSignalR and no accessible extension method addSignalR accepting a first argument of type IServiceCollection could be found(are you missing a using directive or an assembly reference?) How can i configure it? This is the code: var builder = Host.CreateApplicationBuilder(args); builder.Service.AddHostService<Worker>(); builder.Service.addSignalR(); <- here i get the error var host = builder.Build(); host.Run();
13 Replies
Batuhan
Batuhan5mo ago
Could you try to add Microsoft.AspNet.SignalR.Common nuget package to your project and try again ?
Ophélia
Ophélia5mo ago
are you sure the method is called addSignalR and not AddSignalR?
Batuhan
Batuhan5mo ago
this is an another issue i skipped at first
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX5mo ago
how trustable is chatgpt for counting letters ? Now how bad will it be for code, since asking for code often means one cannot fully understand the code and just copy/paste it please don't be suprised that it don't build/don't exist/crash/bug/etc ..... https://cdn.discordapp.com/attachments/569261465463160900/1274310384244756542/image0.jpg
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Batuhan
Batuhan5mo ago
oh yes it did the reason why i suggest him to use common package because i have used in one of my project which is running as a signalr server and i thought he was using server too but thanks again
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Batuhan
Batuhan5mo ago
yes you are right, but does using common instead of client has some vulnerabilities or problem ?
Batuhan
Batuhan5mo ago
btw you were 100% right, i was looking how to use authentication on hub and the first i've looked at the ai to find the solution. Now i noticed that microsoft has clean explanation about that :/ https://learn.microsoft.com/en-us/aspnet/core/signalr/authn-and-authz?view=aspnetcore-8.0
Authentication and authorization in ASP.NET Core SignalR
Learn how to use authentication and authorization in ASP.NET Core SignalR.
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Batuhan
Batuhan5mo ago
got it
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server