[英]How to read a list from appsettings.json and bind it in the mvc dropdownlistfor()
"TransitAgency": [{
"AgencyName": "abc"
"AgencyId": 1
},
{
"AgencyName": "cde"
"AgencyId": 2
}]
enter code here
I have the above json format in app settings file;我在应用程序设置文件中有上述 json 格式; I have to display the above AgencyName in the dropdownlistfor of html view;
我必须在html视图的下拉列表中显示上面的AgencyName; How to achieve this?
如何实现这一目标?
you can extract your array from your appsettings like this:你可以像这样从你的 appsettings 中提取你的数组:
IConfigurationSection section = yourconfig.GetSection("TransitAgency");
var array = section.AsEnumerable();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.