File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 1010
1111var builder = WebApplication . CreateBuilder ( args ) ;
1212
13- // Add services to the container.
13+ // Add configuration
14+ var jwtConfigSection = builder . Configuration . GetSection ( nameof ( JwtSettings ) ) ;
15+ builder . Services . Configure < JwtSettings > ( jwtConfigSection ) ;
1416
17+ // Add services to the container.
1518builder . Services . AddControllers ( ) ;
1619
1720builder . Services
1821 . AddAuthentication ( JwtBearerDefaults . AuthenticationScheme )
1922 . AddJwtBearer ( options =>
2023 {
21- var jwtSettings = builder . Services . BuildServiceProvider ( ) . GetRequiredService < IOptions < JwtSettings > > ( ) . Value ;
24+ var jwtSettings = jwtConfigSection . Get < JwtSettings > ( ) ;
2225
2326 options . TokenValidationParameters = new TokenValidationParameters
2427 {
2932 } ;
3033 } ) ;
3134
32- builder . Services . Configure < JwtSettings > ( builder . Configuration . GetSection ( nameof ( JwtSettings ) ) ) ;
3335builder . Services . RegisterDALDependencies ( builder . Configuration ) ;
3436builder . Services . RegisterBLLDependencies ( builder . Configuration ) ;
3537
You can’t perform that action at this time.
0 commit comments