ASP.Net 5 RC2 configuration section binding
Asked Answered
V

1

13

I have just upgraded my sample app from RC1 to RC2 and I can't find how to bind a specific section of my appSettings.json file to my own POCO anymore.

The sample at https://github.com/aspnet/live.asp.net/blob/rc2/src/live.asp.net/Startup.cs#L47 show that something like this should work:

services.Configure<AppSettings>(options => Configuration.GetSection("AppSettings").Bind(options));

But with the final RC2 bits the "Bind" method or extension method can't be found

Any idea where it lives now or if there is a new approach for this?

Vasos answered 18/5, 2016 at 3:26 Comment(0)
V
11

Ok, found it. It turns out the binder has moved to another package: Microsoft.Extensions.Configuration.Binder

Once I added this package the code in the original question works unchanged

Vasos answered 18/5, 2016 at 3:42 Comment(3)
Always useful to hit Ctrl+. on the line with the error to get an auto suggestion. In ASP.NET Core it will do a search on packagesearch.azurewebsites.net and suggest to add missing package declarationsBalcony
Thanks for that, I didn't know it would do a package search as well. In my case it didn't work though (just got the shortcuts to create new methods, etc...). Maybe because of Resharper getting in the way?Vasos
Maybe, I don't use resharper and it works in Visual Studio 2015 Update 1 and Update 2Balcony

© 2022 - 2024 — McMap. All rights reserved.