InvalidOperationException: No authenticationScheme was specified, and there was no DefaultChallengeScheme found
[Authorize] triggered a challenge, but no authentication handler/default scheme is configured.
Seen on:
.NET
Meaning
AddAuthentication() was called without a default scheme, or not called at all, or UseAuthentication is missing. Specify a default scheme or set schemes on [Authorize].
Common causes
- AddAuthentication() without default scheme
- Authentication handler not registered (AddJwtBearer/AddCookie)
- UseAuthentication/UseAuthorization order wrong
⚡ Quick fix
- Use AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
- Register the handler
- Call app.UseAuthentication() before app.UseAuthorization()
Detailed fix by platform
C#
- csharp
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(); app.UseAuthentication(); app.UseAuthorization();
How to diagnose
- Registration — Schemes configured?
- Middleware — Order
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in .NET
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026