Using IdentityCore with InteractiveServer rendermode (Blazor .NET 8)

I've realised that the IdentityCore login/register pages do not work with InteractiveServer rendermode. I've worked around this by setting the rendermode conditionally rather than globally (InteractiveServer for everything BUT these pages). However, that of course breaks the interactivity of my MainLayout navigation. Can anyone suggest a good way to approach this problem? Ideally, I'd like to use the default login/register pages (with a few tweaks) and have the interactivity of MainLayout still work. I'm a newcomer to Blazor and .NET so I'm not sure what my options are. Any advice is welcome, thanks in advance.
6 Replies
Anu6is
Anu6is4mo ago
Do you need the login to use the mainlayout? you could have it use a separate non-interactive layout
Maverick (Shaun)
I don't need it to, but I would like to, for consistency (if possible)
Anu6is
Anu6is4mo ago
the 2 could have the same look without the interacitvity as you said, the identity pages won't work with interactivity so you don't have much options
mindhardt
mindhardt4mo ago
I personally disabled layout for all Identity pages to reduce confusion In the folder with Identity pages there is a @layout in _Imports.razor
Anu6is
Anu6is4mo ago
<!DOCTYPE html>
<html lang="en">

<head>
.
.
.
<HeadOutlet @rendermode="@RenderModeForPage" />
</head>

<body>
<Routes @rendermode="@RenderModeForPage" />
.
.
.

</body>

</html>

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

private IComponentRenderMode? RenderModeForPage => HttpContext.Request.Path.StartsWithSegments("/Account")
? null
: new InteractiveServer;
}
<!DOCTYPE html>
<html lang="en">

<head>
.
.
.
<HeadOutlet @rendermode="@RenderModeForPage" />
</head>

<body>
<Routes @rendermode="@RenderModeForPage" />
.
.
.

</body>

</html>

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

private IComponentRenderMode? RenderModeForPage => HttpContext.Request.Path.StartsWithSegments("/Account")
? null
: new InteractiveServer;
}
something like this might work too
Maverick (Shaun)
Hmm so rendering parts of the page with different rendermodes? (get back soon, watching Band of Brothers)