dotnet / AspNetCore.Docs

Documentation for ASP.NET Core
https://docs.microsoft.com/aspnet/core
Creative Commons Attribution 4.0 International
12.63k stars 25.29k forks source link

Misleading sentece about use of HttpContext to determine interactivity location #32713

Closed ShahryarSaljoughi closed 4 months ago

ShahryarSaljoughi commented 5 months ago

Description

In the article we read that :

The component makes use of HttpContext to determine if the component is rendering on the server".

In case HttpContext has value, we can be sure that component is rendered using SSR, so it is on the server. However, in case HttpContext is null all we get to know is that the render mode is not "static SSR". We can't determine if it is rendered on client (CSR) or on server (interactive SSR). Hence HttpContext can't be used to determine whether the component is rendering on server or not, as In case of null, it could be server or client.

What I told is based on: This official document

Page URL

https://learn.microsoft.com/en-us/aspnet/core/blazor/components/render-modes?view=aspnetcore-8.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/components/render-modes.md

Document ID

7c9948a3-9886-8097-6014-492a4c21ea4e

Article author

@guardrex

github-actions[bot] commented 5 months ago

πŸ•ΊπŸ’ƒ Happy Cinco de Mayo! πŸ₯³πŸŽˆ

A green dinosaur πŸ¦– will be along shortly to assist. Stand-by ........

guardrex commented 5 months ago

Hello @ShahryarSaljoughi ... BTW WRT that section that you mention ...

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/http-context?view=aspnetcore-8.0#ihttpcontextaccessorhttpcontext-in-razor-components-blazor

... I think it has a flaw in it that's being tracked by another issue. The product unit provided the BWA+OIDC sample with IHttpContextAccessor, and I need to see if that's being used only for static SSR or also being used for interactive SSR, which our doc section says shouldn't be the case (or at least 'not recommended'). I'm going to try and reach that work the end of next week around June 6/7 IF my schedule holds up.

Anyway ... I'll need to take a closer look at your remarks and the comment here and perhaps have Mackinnon from the product unit look it over as well. I'm working on a large tutorial at the moment, so I won't be able to reach this until the end of next week. Thanks for the issue. I'll get back to you! πŸƒ

ShahryarSaljoughi commented 5 months ago

@guardrex Thank you. Hope you do well with the tutorial you working on. No need to rush for this issue. Wish you the best.