I was tasked with experimenting with Duende Software’s Identity Server for a future project. Something strange is happening with the rendering of components which causes the app to lose all of the OIDC claims after logging in. I am having trouble tracking down the cause and possible fix.
I started with this project from the .NET samples https://github.com/dotnet/blazor-samples/tree/main/8.0/BlazorWebAppOidc and hooked up the duende demo server in Program.cs for testing
App.razor is as follows
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="/" />
<link rel="stylesheet" href="bootstrap/bootstrap.min.css" />
<link rel="stylesheet" href="app.css" />
<link rel="stylesheet" href="BlazorWebAppOidc.styles.css" />
<link rel="icon" type="image/png" href="favicon.png" />
<HeadOutlet @rendermode="InteractiveAuto" />
</head>
<body>
<Routes @rendermode="InteractiveAuto" />
<script src="_framework/blazor.web.js"></script>
</body>
</html>
When rendermode is set to InteractiveAuto or InteractiveWebAssembly I am able to log in, redirected back to the home page but then after 5-10 seconds the component appears to render again losing all of the claims. I can see it happens because the top of the tab switches from Home to localhost and then back to Home again
When I set the @rendermode in both HeadOutlet and Routes to InteractiveServer
the re-rendering of the component does not appear to happen and I have all of the correct claims. Strangely, notice how the name no longer appears by the logout button either.
I wasn’t sure if it was related to prerendering either so I went ahead and tried to disable it like this <Routes @rendermode="new InteractiveServerRenderMode(prerender: false)" />
. That ended up doing the exact same thing as the first screenshot except without rendering components twice.
I am totally lost here trying to track this issue down. Any help would be greatly appreciated.