Skip to content

[SignalR][Blazor] HttpContext and IHttpContextAccessor #14974

@javiercn

Description

@javiercn

Provide a doc section on the SignalR docs that provides guidance on the usage of HttpContext and that discourages using IHttpContextAccessor within SignalR.

Indicate that the HttpContext instance might not even exist and that it is dependent on the transport. (For example, websockets gets a single context that is the result of the initial handshake, long polling gets a new context per client "poll" request and signalr service gets a "mocked/faked/shim context")

Explain that accessing the context through IHttpContext accessor is a bad practice as in most cases it will simply be null.

@anurse @davidfowl @BrennanConroy

Activity

javiercn

javiercn commented on Oct 10, 2019

@javiercn
MemberAuthor

We get a bunch of issues like this:
dotnet/aspnetcore#14878

We should have a doc we can point people to.

Rick-Anderson

Rick-Anderson commented on Oct 11, 2019

@Rick-Anderson
Contributor

@BrennanConroy @bradygaster if you can get this drafted we'll help get it published. Should it go in an include so you can include it in multiple docs?

added this to the Backlog milestone on Oct 11, 2019
analogrelay

analogrelay commented on Oct 11, 2019

@analogrelay
Contributor

I think a full doc make sense. Something like "Using HttpContext in SignalR and Blazor Server-Side apps". Perhaps we can have an include that we can put in a few places to put a note call-out something like "Using HttpContext in SignalR or Blazor Server-Side apps has some caveats, see [doc] for details".

We can look at pulling a draft together to start this process. It's definitely something that's affected SignalR users (not just Blazor users).

Rick-Anderson

Rick-Anderson commented on Nov 6, 2019

@Rick-Anderson
Contributor

@BrennanConroy @bradygaster if you can get this drafted we'll get it published. Should it go in an include so you can include it in multiple docs?

31 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      [SignalR][Blazor] HttpContext and IHttpContextAccessor · Issue #14974 · dotnet/AspNetCore.Docs