What is the primary role of a SignalR Hub in ASP.NET applications?
A. To facilitate real-time communication between clients and the server by managing connections and messages.
B. To handle static file serving and HTTP requests.
C. To provide database access and management.
D. To manage user authentication and authorization.
Answer: A
Which class in SignalR is used to handle real-time communication between the client and server?
A. Hub
B. Controller
C. Middleware
D. Service
Answer: A
What does the Hub
class in SignalR allow you to define?
A. Methods that clients can call and methods for sending messages to clients.
B. Database connection settings.
C. Static file paths.
D. HTTP request handlers.
Answer: A
How do you send a message from the server to all connected clients using a SignalR Hub?
A. By using Clients.All.SendAsync()
B. By using SendToAllClients()
C. By calling BroadcastMessage()
D. By invoking PushToAll()
Answer: A
What is the purpose of the HubConnection
class in SignalR?
A. To manage the connection between the client and the SignalR Hub.
B. To handle server-side message processing.
C. To configure client-side data processing.
D. To manage database connections.
Answer: A
How can you handle messages sent from clients to the server in SignalR?
A. By defining methods in the Hub
class that match the method names used by clients.
B. By using custom HTTP endpoints.
C. By configuring server-side request handlers.
D. By using client-side JavaScript functions.
Answer: A
Which method in SignalR allows a server to send a message to a specific client?
A. Clients.Client(clientId).SendAsync()
B. SendToClient(clientId)
C. DirectMessage(clientId)
D. PushToClient(clientId)
Answer: A
What does the OnConnectedAsync
method in a SignalR Hub handle?
A. It manages logic when a client establishes a connection with the Hub.
B. It processes incoming messages from clients.
C. It handles client disconnection events.
D. It configures client-side settings.
Answer: A
How do you manage client disconnections in a SignalR Hub?
A. By using the OnDisconnectedAsync
method.
B. By implementing custom client-side logic.
C. By restarting the server.
D. By configuring server-side settings.
Answer: A
What feature of SignalR allows it to manage messages sent to multiple clients efficiently?
A. Grouping clients and sending messages to specific groups.
B. Using database queries for message distribution.
C. Employing static message queues.
D. Configuring server-side caching.
Answer: A
Which of the following is a correct way to add a client to a group in SignalR?
A. Groups.AddToGroupAsync(connectionId, groupName)
B. AddClientToGroup(connectionId, groupName)
C. JoinGroup(connectionId, groupName)
D. AssignToGroup(connectionId, groupName)
Answer: A
What is the IHubContext<T>
used for in SignalR?
A. To send messages to clients from outside of a Hub class.
B. To manage Hub instances.
C. To configure client-side settings.
D. To handle database connections.
Answer: A
How does SignalR handle message delivery to different clients in the same group?
A. By broadcasting messages to all clients in the group using Clients.Group(groupName).SendAsync()
B. By sending individual messages to each client.
C. By using a shared message queue.
D. By configuring server-side broadcasting settings.
Answer: A
What does the HubLifetimeManager
do in SignalR?
A. It manages the lifecycle and scaling of Hub instances.
B. It configures client-side connections.
C. It handles server-side data processing.
D. It manages user authentication.
Answer: A
Which of the following methods is used to send a message from a Hub to all clients except the caller?
A. Clients.AllExcept(callerId).SendAsync()
B. SendToAllButCaller()
C. BroadcastToOthers()
D. PushToAllExcept()
Answer: A
What is the purpose of the IHubProtocol
interface in SignalR?
A. To handle the serialization and deserialization of messages between the client and server.
B. To manage Hub connection lifecycles.
C. To configure client-side connection settings.
D. To handle server-side data storage.
Answer: A
How can SignalR be used to manage real-time updates in an ASP.NET application?
A. By maintaining a persistent connection between the client and server for immediate message delivery.
B. By using periodic polling mechanisms.
C. By configuring HTTP requests for updates.
D. By employing server-side caching techniques.
Answer: A
What method in SignalR is used to remove a client from a group?
A. Groups.RemoveFromGroupAsync(connectionId, groupName)
B. RemoveClientFromGroup(connectionId, groupName)
C. LeaveGroup(connectionId, groupName)
D. ExcludeFromGroup(connectionId, groupName)
Answer: A
Which of the following describes the Hub
class lifecycle in SignalR?
A. The Hub
class is instantiated per connection and manages real-time communication during its lifetime.
B. The Hub
class is a singleton and shared across all connections.
C. The Hub
class is used for static content delivery.
D. The Hub
class handles database connections.
Answer: A
What is the role of OnReconnectedAsync
in a SignalR Hub?
A. To handle logic when a client reconnects to the Hub after a disconnection.
B. To manage client connection events.
C. To process incoming messages from clients.
D. To configure client-side settings.
Answer: A
How does SignalR support scaling out to multiple servers?
A. By using a backplane such as Redis or Azure SignalR Service for message synchronization.
B. By deploying additional instances of the SignalR service without synchronization.
C. By configuring client-side connection settings for multiple servers.
D. By increasing server resources only.
Answer: A
What is the purpose of the HubCallerContext
in SignalR?
A. To provide information about the client making the request, such as connection ID and user identity.
B. To manage Hub connection settings.
C. To handle server-side message processing.
D. To configure client-side data.
Answer: A
Which SignalR method is used to broadcast messages to a specific group of clients?
A. Clients.Group(groupName).SendAsync()
B. SendToGroup(groupName)
C. BroadcastToGroup(groupName)
D. PushToGroup(groupName)
Answer: A
What does the OnDisconnectedAsync
method handle in SignalR?
A. It manages logic when a client disconnects from the Hub.
B. It processes incoming client messages.
C. It configures client-side connection settings.
D. It handles server-side data processing.
Answer: A
Which of the following features is provided by SignalR for message synchronization across servers?
A. Backplane support, such as Redis or Azure SignalR Service.
B. Manual client-side message handling.
C. Static server configurations.
D. Increased server resources.
Answer: A
How can you handle incoming messages from clients in SignalR?
A. By defining methods in the Hub that match the method names used by clients.
B. By configuring HTTP endpoints on the server.
C. By implementing client-side JavaScript functions.
D. By managing static content.
Answer: A
What does the IHubContext
interface allow you to do in SignalR?
A. Send messages to clients from outside of a Hub class.
B. Manage Hub instances directly.
C. Configure client-side settings.
D. Handle server-side data storage.
Answer: A
Which method in SignalR allows you to send messages to clients in a group?
A. Clients.Group(groupName).SendAsync()
B. SendToGroup(groupName)
C. BroadcastToGroup(groupName)
D. PushToGroup(groupName)
Answer: A
What is the role of IHubLifetimeManager
in SignalR?
A. To manage the lifecycle of Hub instances and facilitate scaling across multiple servers.
B. To handle client-side configuration.
C. To manage server-side data processing.
D. To configure database connections.
Answer: A
Which SignalR class is responsible for handling real-time communication between clients and the server?
A. Hub
B. Middleware
C. Controller
D. Service
Answer: A
How does SignalR ensure real-time communication with minimal latency?
A. By maintaining a persistent connection between client and server.
B. By using periodic polling techniques.
C. By employing static data caching.
D. By configuring server-side message queues.
Answer: A
What does the HubCallerContext
provide information about?
A. The client making the request, including connection ID and user identity.
B. The server-side configuration.
C. The database connection details.
D. The client-side script execution.
Answer: A
How does SignalR handle multiple client connections efficiently?
A. By using groups to organize clients and manage message distribution.
B. By creating separate instances for each client.
C. By using static message queues.
D. By relying on client-side data storage.
Answer: A
What method is used to notify all clients in a specific group of a message?
A. Clients.Group(groupName).SendAsync()
B. BroadcastToGroup(groupName)
C. SendToGroup(groupName)
D. PushToGroup(groupName)
Answer: A
Which of the following is true about SignalR Hub connections?
A. Each client connection is managed individually by the Hub.
B. Connections are shared among all clients.
C. Connections are managed through static configuration.
D. Connections are handled by server-side scripts.
Answer: A
What method allows a server to send messages to all clients except one?
A. Clients.AllExcept(callerId).SendAsync()
B. SendToAllButCaller()
C. BroadcastToOthers()
D. PushToAllExcept()
Answer: A
What is a primary advantage of using SignalR in a web application?
A. It provides a persistent connection for real-time communication, reducing latency compared to traditional methods.
B. It simplifies static file delivery.
C. It enhances database query performance.
D. It improves server-side rendering.
Answer: A