发布后出现内部服务器错误并且未创建表

Internal Server Error after publishing and Tables not being created

此问题仅出现在我发布到的服务器上。我在本地遇到的问题为零。

从 VS2017 发布后,网页显示内部服务器错误,该页面上没有进一步的描述。这不是我第一次发布,所以这个问题很随机。

我束手无策,完全不知道是什么原因造成的。特别是在我点击发布之前,它运行良好。虽然,自从我从 VS 发布以来已经有一段时间了。

我尝试过的事情:

stdoutLog 堆栈跟踪如下:

info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
      User profile not available. Using 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET.0.30319.0\AutoGenKeys\S-1-5-82-1102471511-930544150-2645822985-2987586966-3557056008\DataProtection' as key repository and Windows DPAPI to encrypt keys at rest.
Application startup exception: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: providerInvariantName
   at Serenity.Data.DbProviderFactories.GetFactory(String providerInvariantName)
   at Serenity.Data.SqlConnections.GetFactory(String providerName)
   at Serenity.Data.ConnectionStringInfo.get_ProviderFactory()
   at ApexCore.DataMigrations.EnsureDatabase(String databaseKey) in DataMigrations.cs:line 40
   at ApexCore.DataMigrations.Initialize() in DataMigrations.cs:line 27
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
   at Microsoft.AspNetCore.Server.IISIntegration.IISSetupFilter.<>c__DisplayClass4_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
crit: Microsoft.AspNetCore.Hosting.Internal.WebHost[6]
      Application startup exception

如您所见,它表示 DataMigrations.cs 中出现错误。这并不完全有意义,因为在很长一段时间内,那里的变化都是零。抛出错误的区域超过了创建数据库表的位置。因此,由于表不存在,迁移失败是有道理的。

所以,总而言之...最新发布后网站将无法加载。表没有按应有的方式在数据库中创建。连接字符串是正确的,没有出现无法连接的错误。

我想提一提的是,在 IIS 管理器中的连接字符串下查看时,我注意到那里什么也没有了。这不是应该自动填充我的 AppSettings 中的内容吗?

您可以通过修复程序和功能中的 iis 服务器来解决此问题。
请阅读这个答案。它可能对你有帮助
Specified argument was out of the range of valid values. Parameter name: site

经过多次失败,结果发现当我发布 Release 模式时网站无法运行。但如果我在调试模式下发布,一切都很好。这是一个临时修复,但现在必须这样做。我将不得不研究为什么发布发布模式被打破了。