Overview of SignalR MCQs ASP.NET

What is SignalR primarily used for in ASP.NET applications?
A. Enabling real-time web functionality by providing a persistent connection between client and server.
B. Handling server-side rendering of web pages.
C. Simplifying database access in web applications.
D. Managing static file serving.
Answer: A

Which of the following protocols does SignalR support for real-time communication?
A. WebSocket, Server-Sent Events, and Long Polling.
B. FTP and SMTP.
C. HTTP and HTTPS only.
D. TCP and UDP.
Answer: A

What is the role of a Hub in SignalR?
A. A server-side class that handles real-time communication between clients and the server.
B. A client-side component that manages HTTP requests.
C. A configuration class for SignalR services.
D. A database access layer.
Answer: A

Which method in SignalR is used to send messages from the server to all connected clients?
A. Clients.All.SendAsync()
B. SendToAll()
C. BroadcastMessage()
D. PushToClients()
Answer: A

How does SignalR handle client disconnections and reconnections?
A. By using methods like OnDisconnectedAsync and automatic reconnection policies.
B. By relying on manual client-side reconnection logic only.
C. By restarting the server for reconnections.
D. By configuring static client-side settings.
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 connection management.
C. To configure SignalR services.
D. To process server-side data.
Answer: A

Which SignalR method allows a server to send a message to a specific client?
A. Clients.Client().SendAsync()
B. SendToClient()
C. DirectMessage()
D. PushToClient()
Answer: A

How can you configure SignalR in an ASP.NET Core application?
A. By adding SignalR services in the Startup class and configuring endpoints.
B. By creating custom connection managers.
C. By modifying database connection settings.
D. By setting up static content handlers.
Answer: A

What does the IHubContext<T> interface allow you to do in SignalR?
A. Send messages to clients from outside of a Hub class.
B. Configure client-side settings.
C. Manage server-side data processing.
D. Handle user authentication.
Answer: A

Which of the following is a valid SignalR transport method?
A. WebSocket
B. FTP
C. SMTP
D. HTTP/2
Answer: A

What is the purpose of HubLifetimeManager in SignalR?
A. To manage the lifecycle of Hub instances and support scaling out across multiple servers.
B. To configure client-side scripts.
C. To handle database connections.
D. To manage server-side caching.
Answer: A

Which method in SignalR is used to group clients for sending messages?
A. Groups.AddToGroupAsync()
B. AddClientsToGroup()
C. GroupMessage()
D. AssignToGroup()
Answer: A

How does SignalR ensure that real-time messages are delivered to clients?
A. By using persistent connections and managing message delivery through protocols like WebSocket.
B. By relying on periodic polling mechanisms.
C. By using static HTTP requests.
D. By employing server-side caching.
Answer: A

What does OnConnectedAsync do in a SignalR Hub?
A. It handles logic when a client establishes a connection with the Hub.
B. It manages client disconnection events.
C. It processes incoming messages from clients.
D. It configures client-side settings.
Answer: A

What feature of SignalR allows it to work across different server instances?
A. Backplane support, such as Redis or Azure SignalR Service, for message synchronization.
B. Manual client-side reconnection logic.
C. Single-server deployment.
D. Static configuration of server instances.
Answer: A

Which component in SignalR is responsible for handling real-time communication with clients?
A. Hub
B. Middleware
C. Controller
D. View
Answer: A

What is the main advantage of using SignalR over traditional AJAX polling?
A. SignalR provides a persistent connection for real-time updates, reducing latency and eliminating the need for frequent polling.
B. SignalR improves server-side performance for static content.
C. SignalR simplifies database management.
D. SignalR offers better support for form validation.
Answer: A

Which SignalR feature allows messages to be sent to a subset of connected clients?
A. Groups
B. Broadcasting
C. Multicast
D. Direct Messaging
Answer: A

What does HubConnectionBuilder do in SignalR?
A. It creates and configures a HubConnection instance for the client-side.
B. It manages server-side Hub methods.
C. It handles database connections.
D. It configures server-side data processing.
Answer: A

How can you implement user authentication in a SignalR application?
A. By integrating with ASP.NET Core Identity and using authentication middleware.
B. By managing user credentials within the Hub.
C. By using client-side authentication mechanisms only.
D. By implementing custom authentication schemes in SignalR.
Answer: A

What is the role of IHubProtocol in SignalR?
A. To handle the serialization and deserialization of messages between the client and server.
B. To manage Hub lifecycle events.
C. To configure client-side connection settings.
D. To handle server-side data storage.
Answer: A

Which method in SignalR allows the server to send a message to all clients except the caller?
A. Clients.AllExcept().SendAsync()
B. BroadcastToOthers()
C. SendToAllExcept()
D. PushToOthers()
Answer: A

What is the HubCallerContext used for in SignalR?
A. To provide context information about the caller, such as connection ID and user identity.
B. To manage Hub lifecycle events.
C. To handle client-side scripting.
D. To configure server-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, to handle message synchronization.
B. By deploying multiple instances of the SignalR service without a backplane.
C. By configuring client-side connection settings for multiple servers.
D. By using manual scaling of server resources.
Answer: A

What does OnDisconnectedAsync handle in SignalR?
A. It manages logic when a client disconnects from the Hub.
B. It configures Hub connection settings.
C. It processes incoming client messages.
D. It handles client-side script execution.
Answer: A

Which of the following is NOT a transport protocol used by SignalR?
A. WebSocket
B. Server-Sent Events
C. Long Polling
D. SMTP
Answer: D

How can SignalR be integrated with front-end frameworks like Angular or React?
A. By using the SignalR JavaScript client library to connect with SignalR Hubs.
B. By using custom HTTP endpoints for communication.
C. By embedding SignalR components directly in the front-end framework.
D. By configuring server-side APIs for integration.
Answer: A

What is the purpose of IHubLifetimeManager in SignalR?
A. To manage the lifetime and scaling of Hub instances.
B. To configure Hub methods and client-side scripts.
C. To handle server-side data processing.
D. To manage database connections.
Answer: A

Which method is used to send a message to a specific group of clients in SignalR?
A. Clients.Group().SendAsync()
B. GroupMessage()
C. SendToGroup()
D. BroadcastToGroup()
Answer: A

What feature does SignalR provide for managing user sessions?
A. Integration with ASP.NET Core Identity for user management and authentication.
B. Custom session management directly in the Hub.
C. Client-side session handling only.
D. Database-based session storage.
Answer: A

How does SignalR handle message broadcasting to multiple clients?
A. By using the Clients.All.SendAsync() method for broad communication.
B. By using manual client-side broadcasting logic.
C. By configuring server-side broadcasting settings.
D. By implementing custom broadcasting protocols.
Answer: A

What is the purpose of HubProtocol in SignalR?
A. To define how messages are encoded and decoded between the client and server.
B. To manage client-side connections.
C. To handle server-side data storage.
D. To configure authentication settings.
Answer: A

Which method allows you to send a message from a SignalR Hub to a specific group of clients?
A. Clients.Group(groupName).SendAsync()
B. SendToGroup(groupName)
C. BroadcastToGroup(groupName)
D. PushToGroup(groupName)
Answer: A

What is the role of OnConnectedAsync in a SignalR Hub?
A. To execute logic when a client successfully connects to the Hub.
B. To handle disconnection events.
C. To process incoming client messages.
D. To configure client-side settings.
Answer: A

How can SignalR be scaled to handle high numbers of connections?
A. By using a backplane, such as Redis or Azure SignalR Service, to synchronize messages across servers.
B. By increasing server resources only.
C. By deploying additional SignalR instances without a backplane.
D. By configuring client-side scaling settings.
Answer: A

What is the purpose of the Hub class in SignalR?
A. To define methods that clients can call and to manage communication between the server and clients.
B. To handle database connections.
C. To configure static content.
D. To manage HTTP requests.
Answer: A

How does SignalR support real-time updates in a web application?
A. By maintaining a persistent connection between the client and server for immediate message delivery.
B. By using periodic polling mechanisms.
C. By relying on HTTP requests only.
D. By employing server-side data caching.
Answer: A

Which SignalR method is used to send messages to all clients except the caller?
A. Clients.AllExcept().SendAsync()
B. BroadcastToOthers()
C. SendToAllButCaller()
D. PushToAllExcept()
Answer: A

What is the role of IHubProtocol in SignalR?
A. To handle the serialization and deserialization of messages exchanged between client and server.
B. To manage Hub connection lifecycles.
C. To configure server-side data processing.
D. To handle client-side script execution.
Answer: A

Which method allows a server to send messages to clients who are part of a specific group?
A. Clients.Group(groupName).SendAsync()
B. SendToGroup(groupName)
C. BroadcastToGroup(groupName)
D. PushToGroup(groupName)
Answer: A

How does SignalR manage the connection lifecycle of clients?
A. By providing methods such as OnConnectedAsync and OnDisconnectedAsync for handling connection events.
B. By relying solely on client-side scripts.
C. By configuring static connection settings.
D. By managing connections through a separate service.
Answer: A

What is the main advantage of using SignalR for real-time web applications?
A. It provides a persistent connection for real-time communication, which reduces latency compared to traditional polling.
B. It simplifies database management and query performance.
C. It improves static content delivery speed.
D. It offers enhanced support for server-side rendering.
Answer: A