ASP.Net 5 RC2配置节绑定 [英] ASP.Net 5 RC2 configuration section binding

查看:214
本文介绍了ASP.Net 5 RC2配置节绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将我的示例应用程序从RC1升级到RC2,我找不到如何将我的appSettings.json文件的特定部分绑定到我自己的POCO。

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.

https://上的示例github.com/aspnet/live.asp.net/blob/rc2/src/live.asp.net/Startup.cs#L47 显示这样的东西应该可以工作:

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));

但是使用最后的RC2位,无法找到绑定方法或扩展方法<

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

推荐答案

任何想法现在存在或者是否有新的方法? >

好的,找到了。结果是binder已移动到另一个包:Microsoft.Extensions.Configuration.Binder

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

这篇关于ASP.Net 5 RC2配置节绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆