# InvalidOperationException: No authenticationScheme was specified, and there was no DefaultChallengeScheme found

**Code:** `No authenticationScheme was specified` · **Category:** .NET · **Seen on:** .NET

[Authorize] triggered a challenge, but no authentication handler/default scheme is configured.

## 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

1. Use AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
2. Register the handler
3. Call app.UseAuthentication() before app.UseAuthorization()

## Detailed fix by platform

### C#

1. 

```csharp
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer();
app.UseAuthentication();
app.UseAuthorization();
```


## How to diagnose

1. **Registration** — Schemes configured?
2. **Middleware** — Order

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/dotnet/no-authenticationscheme-specified)
