aspnetcore/blazor/security/includes/troubleshoot-server.md
The server app is a standard ASP.NET Core app. See the ASP.NET Core logging guidance to enable a lower logging level in the server app.
To enable debug or trace logging for Blazor WebAssembly authentication, see the Client-side authentication logging section of xref:blazor/fundamentals/logging with the article version selector set to ASP.NET Core in .NET 7 or later.
Debugger breaks on an exception during logout with Microsoft Entra External ID
The following exception stops the Visual Studio debugger during logout with Microsoft Entra External ID:
:::no-loc text="Uncaught TypeError TypeError: Failed to execute 'postMessage' on 'Window': The provided value cannot be converted to a sequence.":::
The exception is thrown from Entra JavaScript code, so this isn't a problem with ASP.NET Core. The exception doesn't impact app functionality in production, so the exception can be ignored during local development testing.
Misconfiguration of the app or Identity Provider (IP)
The most common errors are caused by incorrect configuration. The following are a few examples:
localhost development testing address, but the app's port configuration and the port where the app is running must match for non-localhost addresses.Configuration coverage in this article shows examples of the correct configuration. Carefully check the configuration looking for app and IP misconfiguration.
If the configuration appears correct:
Analyze application logs.
Examine the network traffic between the client app and the IP or server app with the browser's developer tools. Often, an exact error message or a message with a clue to what's causing the problem is returned to the client by the IP or server app after making a request. Developer tools guidance is found in the following articles:
The documentation team responds to document feedback and bugs in articles (open an issue from the This page feedback section) but is unable to provide product support. Several public support forums are available to assist with troubleshooting an app. We recommend the following:
The preceding forums are not owned or controlled by Microsoft.
For non-security, non-sensitive, and non-confidential reproducible framework bug reports, open an issue with the ASP.NET Core product unit. Don't open an issue with the product unit until you've thoroughly investigated the cause of a problem and can't resolve it on your own and with the help of the community on a public support forum. The product unit isn't able to troubleshoot individual apps that are broken due to simple misconfiguration or use cases involving third-party services. If a report is sensitive or confidential in nature or describes a potential security flaw in the product that cyberattackers may exploit, see Reporting security issues and bugs (dotnet/aspnetcore GitHub repository).
Unauthorized client for ME-ID
info: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[2] Authorization failed. These requirements were not met: DenyAnonymousAuthorizationRequirement: Requires an authenticated user.
Login callback error from ME-ID:
unauthorized_clientAADB2C90058: The provided application is not configured to allow public clients.To resolve the error:
allowPublicClient attribute to null or true.Cookies and site data can persist across app updates and interfere with testing and troubleshooting. Clear the following when making app code changes, user account changes with the provider, or provider app configuration changes:
One approach to prevent lingering cookies and site data from interfering with testing and troubleshooting is to:
C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exeC:\Program Files (x86)\Google\Chrome\Application\chrome.exeC:\Program Files\Mozilla Firefox\firefox.exe-inprivate.--incognito --new-window {URL}, where the {URL} placeholder is the URL to open (for example, https://localhost:5001).-private -url {URL}, where the {URL} placeholder is the URL to open (for example, https://localhost:5001).Firefox Auth Testing.A functioning app may fail immediately after upgrading either the .NET SDK on the development machine or changing package versions within the app. In some cases, incoherent packages may break an app when performing major upgrades. Most of these issues can be fixed by following these instructions:
dotnet nuget locals all --clear from a command shell.bin and obj folders.[!NOTE] Use of package versions incompatible with the app's target framework isn't supported. For information on a package, use the NuGet Gallery.
Blazor Web Apps:
Aspire/Aspire.AppHost project.Blazor Server:
Start the solution from the server project.
The following UserClaims component can be used directly in apps or serve as the basis for further customization.
UserClaims.razor:
@page "/user-claims"
@using System.Security.Claims
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize]
<PageTitle>User Claims</PageTitle>
<h1>User Claims</h1>
@if (claims.Any())
{
<ul>
@foreach (var claim in claims)
{
<li><b>@claim.Type:</b> @claim.Value</li>
}
</ul>
}
@code {
private IEnumerable<Claim> claims = Enumerable.Empty<Claim>();
[CascadingParameter]
private Task<AuthenticationState>? AuthState { get; set; }
protected override async Task OnInitializedAsync()
{
if (AuthState == null)
{
return;
}
var authState = await AuthState;
claims = authState.User.Claims;
}
}