-
Notifications
You must be signed in to change notification settings - Fork 25.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HttpContext is valid in Interactive Server Rendering Blazor page #34301
Comments
Hello @huazhb ... Yes, this is a point of confusion. This section is placed here via an INCLUDE file that also appears in the SignalR article and in the Threat Mitigation article. The section's guidance is the latest that I received from the product unit on the subject. Let's double-check this now and clear this up. @MackinnonBuck ... This is one of the questions on my list of items to address, so we may as well tackle it now. Here's the section (via the INCLUDE) ...
Cross-reference (LIVE section example): https://learn.microsoft.com/en-us/aspnet/core/fundamentals/http-context?view=aspnetcore-8.0#ihttpcontextaccessorhttpcontext-in-razor-components-blazor That came about from my chat with either (or both) you and Javier. There's a related issue on the samples repo about this that boils down to code in the BWA+OIDC sample app ... ... where the |
From Mackinnon offline ...
Ping to @halter73 to take a look at this issue and recommend updates for the section on
Should these remarks include a caveat for client request processing by the server project, including server-side services used by that processing, or is the current guidance just plain wrong? |
We advise against using That said, as far as I know, using However, I do recall @javiercn mentioning that using @BrennanConroy @dotnet/aspnet-blazor-eng In case anyone wants to disagree with or add to my assessment. |
I don't think that's true unless things changed recently.
I believe the context is still from the long running initial request. Although, SSE is not supported by Blazor as it uses a binary message protocol which SSE doesn't support. Blazor has things like pre-rendering and |
Steve remarked offline ...
@javiercn, if you're still happy with what we're telling devs ... ... then I think we just need to say why we're going against the advice in the article for the BWA+OIDC sample app ... If people send a few doc issues after that, then I'll point them to this issue discussion. If I see devs regularly opening doc issues on this, then I propose to add a link to the section (and in the BWA+OIDC article with the new content that I'll add there) along the lines of ...
|
Description
On the website, it says "IHttpContextAccessor must be avoided with interactive rendering because there isn't a valid HttpContext available." which seems not true. I use the IHttpContextAccessor on the Blazor page using Interactive Server rendering and I can access the HttpContext from IHttpContextAccessor without any issue. When switch to Interactive Client it will be null. (Of course it is since it is running on client side). So, I don't know where this statement coming from, or it will be invalid under some circumstances? Can anyone double check if this statement is valid for all Interactive rendering mode or it is only valid for the Interactive client mode?
Thank you
Page URL
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/http-context?view=aspnetcore-8.0
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/http-context.md
Document ID
79cb05f8-9ac0-26a8-8434-15de071160c3
Article author
@guardrex
Related Issues
The text was updated successfully, but these errors were encountered: