Skip to content
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

Is there an alternative to _Host.cshtml.cs? #2

Closed
mrlife opened this issue Oct 4, 2023 · 3 comments
Closed

Is there an alternative to _Host.cshtml.cs? #2

mrlife opened this issue Oct 4, 2023 · 3 comments

Comments

@mrlife
Copy link

mrlife commented Oct 4, 2023

Hi Dan,

Thank you for this upgrade process. It works well. For step 3, is there a new way to handle code from Pages/_Host.cshtml.cs? I have used that to access the request header (HttpContext) values in Blazor apps prior to ASP.NET Core 8.

ref: https://github.com/danroth27/Net8BlazorServer/blob/main/README.md

@danroth27
Copy link
Owner

Hi @mrlife. In .NET 8 RC2 you will be able to access the HttpContext from App.razor as a cascading value like this:

[CascadingParameter]
public HttpContext HttpContext { get; set; }

In .NET 8 RC1 you can use the HttpContext accessor service from static server components as a temporary workaround.

@mrlife
Copy link
Author

mrlife commented Oct 4, 2023

Thank you very much, this is great!

Per docs issue, adding the following: cc: @guardrex dotnet/AspNetCore.Docs#30575

@guardrex
Copy link

guardrex commented Oct 4, 2023

Thx @mrlife ... I'll get it tracked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants