1.配置注入--appsettings.json 可以直接将值注入到视图中
appsettings.json
{
"BlogApi": {
"Url": "http://localhost:65057"
}
}
view视图
@using Microsoft.Extensions.Configuration
@inject IConfiguration Configuration
@{
string myValue = Configuration["BlogApi:Url"];
}