System.InvalidOperationException: Section 'Jwt' not found in configuration. comes from GetRequiredSection("Jwt") when no loaded source has a section of that name. Two causes reproduced here: the section was spelled differently in appsettings.json, and the section lived only in appsettings.Development.json while the app ran as Production. Rename the section, or put it in a file the running environment loads.

Case did not matter here: a section named JWT satisfied GetRequiredSection("Jwt"). A different word, JwtSettings, did not. Req1, JwtSettings and the fix11-*-issuer values are this test's own names. The commands on this page ran in cmd.

The error

dotnet run --no-build --no-launch-profile
Unhandled exception. System.InvalidOperationException: Section 'Jwt' not found in configuration.
   at Microsoft.Extensions.Configuration.ConfigurationExtensions.GetRequiredSection(IConfiguration configuration, String key)
   at Program.<Main>$(String[] args) in C:\...\fixes11\cfg\Req1\Program.cs:line 3
exit=-532462766

The path is shortened; nothing else changed. The stack is two lines: the exception is thrown by the lookup itself, at the line that asked for the section, before builder.Build() and before the app listens on any port. The message names the section it looked for, not the sources it looked in, so the check of each file is yours.

Why it happens

var builder = WebApplication.CreateBuilder(args);

var jwt = builder.Configuration.GetRequiredSection("Jwt");
Console.WriteLine($"Jwt:Issuer = {jwt["Issuer"]}");
...
{
  "AllowedHosts": "*",
  "JwtSettings": {
    "Issuer": "fix11-test-issuer"
  }
}

The code asks for Jwt; the file calls it JwtSettings. GetRequiredSection stopped the app at the first line that needed the section, with the section's name in the message, which is the reason to use it for settings the app cannot run without.

The second cause gives the same message. With appsettings.json holding only AllowedHosts and the section in appsettings.Development.json:

dotnet run --no-build --no-launch-profile -e ASPNETCORE_ENVIRONMENT=Production
Unhandled exception. System.InvalidOperationException: Section 'Jwt' not found in configuration.
...
dotnet run --no-build --no-launch-profile -e ASPNETCORE_ENVIRONMENT=Development
Jwt:Issuer = fix11-dev-issuer
exit=0

The fix

For the spelling, rename the section in the file to the name the code uses:

{
  "AllowedHosts": "*",
  "Jwt": {
    "Issuer": "fix11-test-issuer"
  }
}
dotnet run --no-build --no-launch-profile
Jwt:Issuer = fix11-test-issuer
exit=0

An earlier run with the section named upper-case "JWT" printed the same line, so in this run the upper-case name was accepted too.

For the Production case, the section can come from the environment. With no Jwt section in any file (only appsettings.json, holding AllowedHosts) and only the variable set, the same call found it under Production:

set Jwt__Issuer=fix11-env-issuer& dotnet run --no-build --no-launch-profile -e ASPNETCORE_ENVIRONMENT=Production
Jwt:Issuer = fix11-env-issuer
exit=0

Moving the section into appsettings.json, the other way out, is the fix run above.

How it was reproduced

A project from dotnet new web -f net10.0 with SDK 11.0.100 on Windows 11, no packages added, the template's appsettings.Development.json moved out for the first runs. The program called GetRequiredSection("Jwt") at start-up, printed the issuer; it exited instead of serving because the lab set FIX11_NO_SERVE=1 and Program.cs returns before app.Run() when it is set (cut from the excerpt above). It ran with the section named JwtSettings, JWT and Jwt, with the section only in a new appsettings.Development.json under Production and Development, and with no section in any file and Jwt__Issuer set under Production. Every command shown without a PS> marker ran in cmd: a PowerShell script passed it as cmd /c ... 2>&1 and printed the exit= line after it.

Frequently asked

How do I fix Section not found in configuration?
Make a section with the exact name passed to GetRequiredSection exist in a source the running environment loads. In this test renaming the section JwtSettings to Jwt in appsettings.json fixed it, and an environment variable Jwt__Issuer with no section in any file also satisfied the call.
Is GetRequiredSection case sensitive?
No, not in this test: a section named JWT in appsettings.json satisfied GetRequiredSection("Jwt") and its values were read.
Why does GetRequiredSection work in Development but not in Production?
In this test the section was only in appsettings.Development.json. Under Production the call threw Section 'Jwt' not found in configuration; under Development it printed the value.

More decoded errors in the Fixes category. The same Development-only trap with user-secrets is in Value cannot be null in Production.