how to use signalr in minimal api?

mc 4,836 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,684 questions
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 68,306 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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.