dotnet / dotnet/AspNetCore.Docs

[SignalR] How Hubs interact with HttpContext

Open
#13,508 4 comments 4 reactions 0 assignees View on GitHub
doc-idea SignalR
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.