【发布时间】:2017-02-24 13:17:36
【问题描述】:
我有一个我想在 IIS 7.5 中托管的 asp.net core web api 项目。
正如以下文章所建议的,
The configuration file 'appsettings.json' was not found and is not optional
下面是我的“appsettings.json”文件,
{
"ConnectionStrings": {
"SchedulerConnection": "Server=ABC\\SQL2012;Database=SchedulerDb;persist security info=True;Integrated Security=SSPI;"
}
}
在“startup.cs”中,我得到如下连接字符串值,
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<SchedulerContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("SchedulerConnection"),
b => b.MigrationsAssembly("WebTest.API")));
}
代码在本地 IISExpress 中运行文件,但在部署到 IIS 7.5 时抛出 500 Server Error。
这里有什么问题?请指教!!
下面是我的“publishOptions”,
"publishOptions": {
"include": [
"wwwroot",
"appsettings.json",
"web.config"
]
},
【问题讨论】:
-
现在我可以获得连接字符串,但是在将它托管到 IIS 7.5 之后,我收到 500 Internal Server Error,知道吗?