-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Blazor Identity with Global RenderMode #51476
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
Comments
This will be fixed in next GA version. If you enable the Global RenderMode as Server, the project template for now will make all the pages rendered as server, which means there will be no HttpContext. You can check issue #51134 to preview the change. The Account pages will be rendered static even if you enable the global rendermode. Account pages rely on SignInManager which needs the HttpContext, so they have to be rendered as Static. |
Found the same issue, good to see it will be fixed in GA. I was having trouble figuring out a workaround. |
Found A workaround where you can leave everything on Interactive, but if you navigate to the /Account-Pages you switch to a Static or "null" Rendermode. Just add or change those lines in your
Sideeffect is that when you want to use your ThemeSwitcher or any other interactive component declared in your MainLayout.razor they wont work anymore, so its best to remove or comment out this Line from your
so that only the content from your /Account-Pages gets rendered without the now noninteractive "interactive" components. And to make it look a little prettier you can add some css in AccountLayout.razor in a style-tag like so:
to center everything. In my /Account-Pages i then removed the "col"- and "row"-classes from the divs and added a cancel-button.
|
thanks Mabulla you saved my day thumbs up!!. |
Is there an existing issue for this?
Describe the bug
Making a new Blazor WebApp in RC2, if you select individual accounts and Global Interactive server mode:
The template does not automatically add
@rendermode="RenderMode.InteractiveServer"
to the App.razor Routes and Head Outlet components. This only occurs when using the new identity pages, when they are excluded, the rendermode is automatically added.When you manually add the global rendermode in, the identity pages begin giving Null Reference Exceptions in several locations. For example: visiting the Register Page throws a null reference exception in StatusMessage.razor @ line 28:
private string? MessageFromCookie => HttpContext.Request.Cookies[IdentityRedirectManager.StatusCookieName];
Removing the global rendermode from the Routes component stops the exceptions, but then eliminates the needed functionality.
Expected Behavior
The expected behavior was to be able to use the Interactive Server Render Mode globally with the new razor identity pages.
Steps To Reproduce
@rendermode="RenderMode.InteractiveServer"
to the HeadOutlet and Routes components in /Components/App.razor.Exceptions (if any)
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=BlazorApp1
StackTrace:
at BlazorApp1.Components.Identity.StatusMessage.get_MessageFromCookie() in F:\BlazorApp1\BlazorApp1\Components\Identity\StatusMessage.razor:line 28
.NET Version
.NET8 RC2
Anything else?
No response
The text was updated successfully, but these errors were encountered: