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 Hubs (to allow portability to non-HTTP transports)
We should have a document describing the complex interations between Hubs and
HttpContext.HttpContextviaContext.GetHttpContext()extension method, but it's not guaranteed to workIHttpContextAccessorshould be avoidedHttpContextso it's considered a good design practice to avoid usingHttpContextat all inHubs (to allow portability to non-HTTP transports)