错误代码
public Startup()
{
var builder = new ConfigurationBuilder().AddJsonFile("AppSetting.json");
Configuration = builder.Build();
}
修改
public Startup(IHostingEnvironment environment)
{
var builder = new ConfigurationBuilder().SetBasePath(environment.ContentRootPath).AddJsonFile("AppSetting.json");
Configuration = builder.Build();
}
或
public Startup()
{
var buiider = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("AppSettings.json");
Configuration = buiider.Build();
}
.NET Core The configuration file 'appsettings.json' was not found and is not optional
原文地址:https://www.cnblogs.com/zj0602/p/9876382.html
时间: 2024-09-30 20:35:31