我正在OS X上构建Asp.Net MVC(.Net Core 2.0)应用程序。
将appsettings.json
修改为:
{
"AppSettings": {
Interval": 15
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
}
}
构建成功,但执行在WebHost.CreateDefaultBuilder
文件的Program.cs
行停止:
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
我错过了什么吗?
答案 0 :(得分:1)
看起来您的appsettings不是有效的JSON。你错过了Interval周围的双引号。尝试
{
"AppSettings": {
"Interval": 15
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
}
}
答案 1 :(得分:-1)
您只需遵循此格式即可。
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
},
"Config1": {
"Key": "value"
},
"Config2": {
"Key1": "value1",
"key1": "value2"
}