WebSockets
Chat, live dashboards and notifications keep a WebSocket connection open. IIS needs one feature installed to allow it.
On this page · 5 min · Advanced
On this page
- Learning objectives
- Explanation
- Step-by-step screens
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Advanced
- Updated
- Nov 26, 2026
Related tutorials
Interview questions
Learning objectives#
- Install the WebSocket Protocol feature
- Check the webSocket configuration
- Proxy WebSockets with ARR
- Avoid connections being dropped
Explanation#
Install Web Server → Application Development → WebSocket Protocol. Without it, ASP.NET Core SignalR silently falls back to slower Server-Sent Events or long polling.
The section system.webServer/webSocket (Configuration Editor) has enabled = true by default once installed. Don’t disable it in web.config.
For a back end behind IIS (Node.js, Kestrel on another port), ARR 3 forwards WebSocket upgrades through a normal reverse proxy rule.
Load balancers and proxies close idle connections (often after 60–120 seconds). SignalR sends keep-alive pings; for raw WebSockets send your own pings.
Step-by-step screens#
Drawings of IIS Manager in IIS 10 (Windows Server 2019/2022, Windows 10/11). The red numbers match the numbered actions under each picture; names on your computer will differ.
Loading pictures…
Code example: Check in the browser which transport SignalR uses#
builder.Services.AddSignalR();
var app = builder.Build();
app.MapHub<OrdersHub>("/hubs/orders");
app.Run();
// In the browser console (F12) of the page that connects:
// [2026-11-26T10:20:01Z] Information: WebSocket connected to wss://shop.example/hubs/orders?id=...
// If you see "ServerSentEvents connected" instead, the WebSocket Protocol feature is missing.
With the feature installed the browser log shows “WebSocket connected to wss://…”, and the Network tab shows a 101 Switching Protocols response.
This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.
Step-by-step explanation#
- The hub is mapped at /hubs/orders.
- The SignalR client tries WebSockets first.
- 101 Switching Protocols confirms the upgrade.
- A fallback transport means IIS isn’t allowing WebSockets.
Real-world use case#
An order dashboard showed new orders with a delay of several seconds. Installing the WebSocket Protocol feature switched SignalR from long polling to WebSockets and updates became instant.
Common mistakes#
Everything “works” with a fallback, just slower and with more requests. Check the transport.
Connections drop every minute. Use keep-alives and raise the idle timeout.
Best practices#
- Install WebSocket Protocol
- Check for 101 in DevTools
- Use sticky sessions or a backplane with several servers
- Configure keep-alives
Remember this#
Role service: WebSocket Protocol.
101 Switching Protocols = success.
ARR 3 proxies WebSockets.
Practice exercise#
Your task: Which HTTP status code confirms a successful WebSocket upgrade?
Show solution
101 Switching Protocols
Mini quiz#
What happens to SignalR if IIS lacks WebSocket support?
Want more? Practise all IIS MCQs · IIS interview questions
My notes#
Saved in this browser.