dotnet / dotnet/AspNetCore.Docs
[SignalR] How Hubs interact with HttpContext
- Dominant language
- C#
- Stars
- 13.1k
- Forks
- 24.6k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 97
Description
We should have a document describing the complex interations between Hubs and `HttpContext`.
* In a Hub you can get an `HttpContext` via `Context.GetHttpContext()` extension method, but it's not guaranteed to work
* Long Polling uses a "simulated" context
* There's no context at all when using Azure SignalR
* `IHttpContextAccessor` should be avoided
* SignalR has some support for non-HTTP transports (nothing officially supported yet but some future ideas) and those wouldn't even have an `HttpContext` so it's considered a good design practice to avoid using `HttpContext` at all in `Hub`s (to allow portability to non-HTTP transports)
Contributor guide
Assessment
This issue has not been assessed yet.