[英]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
我在應用程序設置文件中有上述 json 格式; 我必須在html視圖的下拉列表中顯示上面的AgencyName; 如何實現這一目標?
你可以像這樣從你的 appsettings 中提取你的數組:
IConfigurationSection section = yourconfig.GetSection("TransitAgency");
var array = section.AsEnumerable();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.