System.InvalidOperationException: The AuthorizationPolicy named: 'AdminOnly' was not found. means an endpoint asks for a policy by a name that AddAuthorization never registered. In this test the policy was added as "AdminsOnly" and the endpoint asked for "AdminOnly": one letter apart, and the request sent to that endpoint failed with a 500.

Make the two names the same string. The safest way is to keep each policy name in one constant and use the constant in both places, so a typo becomes a compile error instead of a runtime one.

The error

The request to the protected endpoint got this response (the Development exception page; curl sent Accept: */*, as the page's own HEADERS list shows, and the page came back as text/plain), and the server console logged the same exception:

PS> curl.exe -s -i http://127.0.0.1:15630/reports
HTTP/1.1 500 Internal Server Error
Content-Type: text/plain; charset=utf-8
Date: Sat, 14 Nov 2026 01:13:45 GMT
Server: Kestrel
Transfer-Encoding: chunked

System.InvalidOperationException: The AuthorizationPolicy named: 'AdminOnly' was not found.
   at Microsoft.AspNetCore.Authorization.AuthorizationPolicy.CombineAsync(IAuthorizationPolicyProvider policyProvider, IEnumerable`1 authorizeData, IEnumerable`1 policies)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
...

Why it happens

The code that produced it registers one policy and asks for another:

...
builder.Services.AddAuthorization(options =>
{
    options.AddPolicy("AdminsOnly", policy => policy.RequireRole("admin"));
});
...
app.MapGet("/reports", () => "Monthly report").RequireAuthorization("AdminOnly");
...

Policy names are plain strings, so the compiler has nothing to check. The app built with 0 warnings and started normally. The exception came only when a request reached /reports, from AuthorizationMiddleware; the request carried no token at all and got the 500, not a 401.

The fix

...
builder.Services.AddAuthorization(options =>
{
    options.AddPolicy(Policies.AdminOnly, policy => policy.RequireRole("admin"));
});

var app = builder.Build();

app.UseAuthentication();
app.UseAuthorization();

app.MapGet("/reports", () => "Monthly report").RequireAuthorization(Policies.AdminOnly);

app.Run();

static class Policies
{
    public const string AdminOnly = "AdminOnly";
}

With the names matched, the same request without a token got the answer an anonymous caller should get:

PS> curl.exe -s -i http://127.0.0.1:15630/reports
HTTP/1.1 401 Unauthorized
Content-Length: 0
Date: Sat, 14 Nov 2026 01:13:47 GMT
Server: Kestrel
WWW-Authenticate: Bearer

If the policy lives in another project or is registered conditionally (only in some environments, say), check that the registration actually runs in the environment where the request fails. Searching the solution for the exact quoted name in the message is the quickest way to find the two spellings.

How it was reproduced

A minimal API made with dotnet new web -f net10.0 on SDK 11.0.100, with Microsoft.AspNetCore.Authentication.JwtBearer 10.0.0 for the scheme, running on Microsoft.AspNetCore.App 10.0.15 in the Development environment, built and started by a small script, start.ps1, which runs dotnet build -nologo -v q in the project folder and then bin\Debug\net10.0\FixLab.exe --urls http://127.0.0.1:15630. One endpoint required the misspelled policy; a single curl.exe request without a token triggered the exception, and the same request after the fix returned 401.

Frequently asked

What does 'The AuthorizationPolicy named was not found' mean in ASP.NET Core?
An endpoint asked for a policy by name, and no policy with that exact name was added in AddAuthorization. The request fails with a 500 when it reaches the authorization middleware.
Why does the policy error appear at request time and not at startup?
Policy names are strings. In the test the app built and started without a warning, and the exception came only when a request reached the endpoint that named the missing policy.
How do I stop policy name typos in ASP.NET Core?
Keep each policy name in a constant, for example a static Policies class, and use the constant both in AddPolicy and in RequireAuthorization or the Authorize attribute. A typo then fails to compile.

More decoded errors in the Fixes category. If the 500 says instead that no middleware supports authorization, see 'a middleware was not found that supports authorization'.