Regarding Blazor and IHttpContextAccessor #25755
-
According to the page below you should avoid using IHttpContextAccessor in Blazor Server Apps. My question regarding this is: Is there a risk that you might get access to the HttpContext from another user's session or is the risk only that you could get Null or a HttpContext that is related to you but is from another request? I found the example that shows how to retrieve information from the HttpContext in the page and propagate it further. I saw this issue that seems to be resolved and which seems to take care of the risk of getting the wrong HttpContext, but I don't really know how it relates to Blazor Server Does anyone know what the real caveats and risks are when using IHttpContextAccessor in Blazor Server? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I think you can't count on @javiercn Do you have anything to add to this? |
Beta Was this translation helpful? Give feedback.
I think you can't count on
IHttpContextAccessor
returning anything. Our recommended deployment environment for Blazor Server is using the Azure SignalR service (see: Deploying Blazor Server), and in this case, there won't be any HttpContext associated with the connections.@javiercn Do you have anything to add to this?