Closed xatabhk closed 8 years ago
I have the same problem, have you solved it?
Try
services.Configure<AppSettings>(Configuration.GetSection("AppSettings"));
I got it, @davidfowl is right.
I had read the docs and known "setup the IOptions
@davidfowl
No. services.Configure
But I have found a workaround for this issue as follows:
services.Configure
Still, settings are not loaded automatically.
@xatabhk It does work, the syntax (and namespace) probably changed
@davidfowl Buit it does not work as expected. User has to do property/field mapping manually like this: xx.SiteTitle=Configuration.GetSection("AppSettings")["SiteTitle"];
Nah, can you provide the fully non working sample? Pushing to a github repo with instructions would be best.
@xatabhk the Configure<T>()
extension methods that take an IConfiguration
where moved to a new package (Microsoft.Extensions.Options.ConfigurationExtensions) to decouple dependencies. See #97 for more information.
appsettings.cs:
appsettings.json:
Startup.cs:
xview.cshtml:
And all fields like SiteTitle in MyAppSettings are always null.