将asp.net core web api部署到IIS 7.5时出现500错误

时间:2016-10-15 03:00:58

标签: asp.net-core-webapi

我有一个asp.net核心web api项目,我试图在IIS 7.5中托管。

如下文所述,

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服务器错误。

这里有什么问题?请建议!!

以下是我的“publishOptions”,

"publishOptions": {
"include": [
  "wwwroot",
  "appsettings.json",
  "web.config"
]
 },

2 个答案:

答案 0 :(得分:0)

创建新登录&#34; IIS APPPOOL [应用程序池名称]&#34;对于SQL Server和以后将网站/ IIS应用程序分配给&#34; IIS APPPOOL [应用程序池名称]&#34;适合我。

谢谢,

答案 1 :(得分:0)

将服务器指向* \ bin \ Release \ PublishOutput。

选择ApplicationPool .Net Framework版本为&#34;没有托管代码。&#34; 和过程模型 - &gt;标识为LocalSystem。

重新启动。

如果出现相同的500错误,请尝试自我托管。 链接:https://stackoverflow.com/questions/30298458

您将了解应用程序中的错误。

然后再次发布并重新托管。