How do I access connectionString and jwtSwitting in 'host.settings.json'?
like this (it's not hotchocolate project, it's normal dotnet api): appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft.AspNetCore": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"Default": "Server=localhost; User=root; Database=FINDUS; Password=xxxxxx"
},
"JwtSettings": {
"SigningKey": "23kfioejrkdjfkelrkdoemvasde31sxnmd",
"Issuer":"CwkSocial",
"Audiences":["SwaggerUI"]
}
}
Program.cs(access jwtSettings):
var jwtSettings = new JwtSettings();
builder.Configuration.Bind(nameof(JwtSettings), jwtSettings);
var jwtSection = builder.Configuration.GetSection(nameof(JwtSettings));
builder.Services.Configure<JwtSettings>(jwtSection);
the example is not hotchocolate project.
For accessing variables in isolated
local.settings.json
you could try this:JwtSettings.cs
Test