how to use signalr in minimal api?

mc 3,701 Reputation points
2024-04-29T13:33:56.15+00:00

can not use AddSignalR and I can use AddSignalRCore but there will be error.

I created the ASP.NET Core Web API (native aot).

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,227 questions
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 57,481 Reputation points
    2024-04-29T15:33:46.1566667+00:00

    in net 8 min api its:

    builder.Services.AddSignalR();
    
    ...
    
    app.MapHub<MyHub>("/myHub");
    

    note: the signal/r library can not be compiled to native aot and is not supported. you can use websockets. see:

    https://learn.microsoft.com/en-us/aspnet/core/fundamentals/native-aot?view=aspnetcore-8.0


0 additional answers

Sort by: Most helpful