https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/web-host
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft.AspNetCore": "Debug"
}
}
}
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*", // a sor végére bekerült egy vessző
"DummySettings": {
"DefaultString": "My Value",
"DefaultInt": 23,
"SuperSecret": "Spoiler Alert!!!"
}
}
public class DummySettings
{
public string? DefaultString { get; set; }
public int DefaultInt { get; set; }
public string? SuperSecret { get; set; }
}
builder.Services.Configure<DummySettings>(
builder.Configuration.GetSection(nameof(DummySettings)));
private DummySettings options;
public DummyController(IOptions<DummySettings> options)
{
this.options=options.Value;
}
[HttpGet("{id}", Name = "Get")]
public string Get(int id)
{
return id % 2 == 0 ? (options.DefaultString ?? "value") : options.DefaultInt.ToString();
}
{
"DummySettings": {
"DefaultString": "My Value",
"DefaultInt": 23,
"SuperSecret": "SECRET"
}
}