Skip to content

Can I use the new razor Identity UI from .NET8 in Blazor Server Side? #53893

Closed
@twojnarowski

Description

@twojnarowski

Summary

In this article What’s new with identity in .NET 8
it is stated that:

The new version is built with Razor components and works with both server-side and WebAssembly Blazor apps.

However here In SSR, supply HttpContext as cascading value #50253 it is stated that:

In SSR, this will receive the HttpContext. In other rendering modes where there is no HTTP context, no value will be supplied so the property will remain null.

So these two statements conflict with each other, because in the new .NET8 Blazor template for example the Login.razor page needs the HttpContext:

[CascadingParameter] private HttpContext HttpContext { get; set; } = default!;

Other pages also use the RedirectManager.RedirectToCurrentPageWithStatus method which needs HttpContext as a parameter.

I have created a new project using this template:
image
And selected the Interactive render mode "Server"
And now when I start this application, I can see during debugging that the HttpContext from Cascading Parameter is not actually null:
image

In this template, the Program.cs has these lines:

builder.Services.AddRazorComponents()
    .AddInteractiveServerComponents();

Am I correct to assume that means I am using what used to be Blazor Server Side nad now Interactive Server Side Rendering? And if yes, then why in such case the HttpContext is not null?

Motivation and goals

I would like to use the new Blazor Identity UI in the application which I updated from .NET7 to .NET8

In scope

Clarification as to how can I use Identity in Blazor SS.
Do I still need _Host.cshtml to extract authentication information from HttpContext during application load?
Can I use new Identity razor components in Blazor SS-only application?
Can I access HttpContext in a Blazor SS-only application?
Is Blazor Server Side now renamed "interactive SSR" in the documentation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedarea-blazorIncludes: Blazor, Razor Componentsdesign-proposalThis issue represents a design proposal for a different issue, linked in the descriptionquestion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions