【问题标题】:500 error while deploying asp.net core web api to IIS 7.5将 asp.net core web api 部署到 IIS 7.5 时出现 500 错误
【发布时间】: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,知道吗?

标签: asp.net-core-webapi


【解决方案1】:

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

选择 ApplicationPool .Net Framework 版本作为“无托管代码”。 和 Process Model->Identity as LocalSystem。

重启两者。

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

您将知道您的应用程序中的错误。

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

【讨论】:

    【解决方案2】:

    为 SQL Server 创建一个新的登录名“IIS APPPOOL[App Pool Name]”,然后将网站/IIS 应用程序分配给“IIS APPPOOL[App Pool Name]”对我有用。

    谢谢,

    【讨论】:

      猜你喜欢
      • 2020-12-24
      • 1970-01-01
      • 1970-01-01
      • 2016-07-27
      • 2021-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-27
      相关资源
      最近更新 更多