Code: Select all
"CustomSite": {
"Management": {
"Confined": {
"DefaultUILanguage": "en-GB",
"Id": "123456",
"MainDomLock": "True"
},
"ThirdParty": {
"Results": {
"Team": {
"Settings": {
"InformtionId": "123",
"AdminKey": "456"
}
}
}
},
public class TeamSettings
{
public string? InformationId { get; set; } = string.Empty;
public string AdminKey { get; set; } = string.Empty;
}
< /code>
Ich habe es registriert < /p>
....Services.Configure(builder.Configuration.GetSection(nameof(TeamSettings)));
< /code>
Aber wenn ich versuche, den Wert zu erhalten - ist es immer null - warum? < /p>
IOptions teamSettings
< /code>
Dann < /p>
teamSettings.Value.InformationId; // is always null
< /code>
Nach einigen Lesen habe ich versucht, es zu ändern, um: < /p>
Services.Configure(builder.Configuration
.GetSection("CustomSite")
.GetSection("Management")
.GetSection("ThirdParty")
.GetSection("Results")
.GetSection(nameof(TeamSettings)));
< /code>
Es ist jedoch auch null. < /p>
Was mache ich falsch? Überprüfte andere ähnliche Themen und Dokumente, aber mir fehlt mir irgendwo eindeutig etwas?