I keep reading that IHttpContextAccessor
should not be used with Blazor applications at all. However, the suggested approaches all seem to focus only on usage within a component. I am trying to access the http context during policy authorization, and I don't see a clear way to do this without injecting IHttpContextAccessor
. Is it problematic during authorization as well?
Additionally, again for security reasons, you must not use IHttpContextAccessor within Blazor apps. Blazor apps run outside of the context of the ASP.NET Core pipeline. The HttpContext isn't guaranteed to be available within the IHttpContextAccessor, nor is it guaranteed to be holding the context that started the Blazor app.
Edit: This is not a duplicate question as I am talking about a specific location and a different era of Blazor (Microsoft's statement basically forbidding its use entirely didn't exist at the time of the question mine supposedly duplicates). Both the question and answers there do not address my specific use case (during authorization). I am asking about a specific place in which the _Host.cshtml is irrelevant as the authorization handler code is executed before _Host according to the order my breakpoints are being hit.