成功Value cannot be null. (Parameter 'connectionString')解决

今天发布了asp.net core并部署到服务器,在开发工具中运行一切正常,用部署后的程序前端一直连接不上后台core,调试发现前端一直报个错误:Value cannot be null. (Parameter 'connectionString'),数据库一直没执行。查找了很多方法,最后发现,原来是appsettings.json没有数据库连接字符串造成的。加上连接字符串,一切ok。直接上代码

修改前:

{

"Logging": {

"LogLevel": {

"Default": "Information",

"Microsoft": "Warning",

"Microsoft.Hosting.Lifetime": "Information"

}

},

"AllowedHosts": "*",

}

修改后:

{

"Logging": {

"LogLevel": {

"Default": "Information",

"Microsoft": "Warning",

"Microsoft.Hosting.Lifetime": "Information"

}

},

"AllowedHosts": "*",

"ConnectionStrings": {

"MainDb": "Server=xxxxx;Database=xxx;User ID=sa;Password=xxx"

}

}

(0)

相关推荐