Sobes.tech
Junior — Middle

What is the main function and application of the SignalR library in modern web applications?

sobes.tech AI

Answer from AI

SignalR is a .NET library that simplifies real-time bidirectional communication between server and client in web applications. Its main function is to provide instant data transfer, for example, for chats, notifications, or live data updates without page refresh.

SignalR automatically chooses the best available transport (WebSocket, Server-Sent Events, Long Polling) for connection, simplifying real-time development.

Example of using SignalR in ASP.NET Core:

public class ChatHub : Hub
{
    public async Task SendMessage(string user, string message)
    {
        await Clients.All.SendAsync("ReceiveMessage", user, message);
    }
}

Here, the server sends a message to all connected clients in real-time.

What is the main function and application of the… - sobes.tech