Blazor application is logged in then logs itself out

  Kiến thức lập trình

I’ve got a Blazor application with authentication against IdentityServer.

After logging in I go to this page:

@page "/LoggedIn"
@attribute [Authorize]
<p>Claims:</p>
<ul>
    @foreach( Claim c in HttpContext.User.Claims)
    {
        <li><code>@c.Type</code>: <code>@c.Value</code></li>
    }
</ul>

<h2>Here is the counter</h2>

<BlazorAppWithIdentity.Client.Pages.Counter></BlazorAppWithIdentity.Client.Pages.Counter>

<h2>Here is the auth</h2>

<BlazorAppWithIdentity.Client.Pages.Auth></BlazorAppWithIdentity.Client.Pages.Auth>


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

When the page loads both the server side (top) section and the client side (bottom) section show the list of claims.

Then, after a few second, the bottom section disappears — presumably becuse the client side code thinks that the user isn’t authenticated.

What is causing this?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT