【发布时间】:2022-10-01 02:37:45
【问题描述】:
我的“appsettings.json”中有这个
\"AllowedHosts\": \"*\",
\"AlprReport\": {
\"ConnectionAddress\": \"http://192.168.100.37:81/alprreport/cashdeclaration\"
}
我试着把它放在我的 Razor 中:
public RazorComponent : ComponentBase
{
[Inject] IConfiguration configuration;
public void SomeMethod()
{
var result = configuration.GetSection(\"AlprReport:ConnectionAddress\").Value
}
}
我总是得到空值的结果。我尝试使用以下方法从我的“Program.cs”中获取它:
var alprReport = builder.Configuration.GetSection(\"AlprReport:ConnectionAddress\").Value;
我仍然无法让它工作。我在这里做错了什么?谢谢。
-
你的 appsettings.json 文件在哪个目录?
标签: asp.net-core blazor