我正在尝试将 ASP.NET MVC Core 2 站点部署到运行 IIS 10 的Windows Server 2016服务器,并且我在应用程序日志中收到以下错误
我已经研究了这个问题并发现了这个.NET Core app unable to start in IIS due to ErrorCode = '0x80004005 : 80008083的问题,答案是:"因为VS2017 RC附带了新版本的.NET Core SDK(.NET Core 1.0.4 SDK) 1.0.1),您还需要在服务器上更新框架。"
我已尝试在服务器上安装SDK和运行时,如上面的答案所示,但我在导航到网站时仍然收到错误。
如何解决此问题?
Faulting application name: dotnet.exe, version: 2.0.25816.2, time stamp: 0x59e535ea
Faulting module name: coreclr.dll, version: 4.6.25815.2, time stamp: 0x59e2b767
Exception code: 0xc00000fd
Fault offset: 0x000000000008247a
Faulting process id: 0x1c68
Faulting application start time: 0x01d36aeaea2429cf
Faulting application path: C:\Program Files\dotnet\dotnet.exe
Faulting module path: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.3\coreclr.dll
Report Id: 100b3c83-7509-487e-b1cd-6a0357f8b7e7
Faulting package full name:
Faulting package-relative application ID:
答案 0 :(得分:1)
运行以下命令会显示真正的错误:
C:\Windows\system32>"C:\Program Files\dotnet\dotnet" C:\inetpub\wwwroot\{YOUR_IIS_SITE_NAME}\{YOUR_PROJECT_NAME}.dll
命令提示符中的结果如下,告诉我连接字符串中有错误:
C:\Windows\system32>"C:\Program Files\dotnet\dotnet" C:\inetpub\wwwroot\www_projectx_com\ProjectX.dll
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using 'C:\Users\darchual\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[58]
Creating key {70b30c91-49df-45be-95cc-2e681b5cde76} with creation date 2017-12-04 16:34:08Z, activation date 2017-12-04 16:34:08Z, and expiration date 2018-03-04 16:34:08Z.
info: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[39]
Writing data to file 'C:\Users\darchual\AppData\Local\ASP.NET\DataProtection-Keys\key-70b30c91-49df-45be-95cc-2e681b5cde76.xml'.
Unhandled Exception: System.ArgumentNullException: Value cannot be null.
Parameter name: connectionString
at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
at Microsoft.EntityFrameworkCore.SqlServerDbContextOptionsExtensions.UseSqlServer(DbContextOptionsBuilder optionsBuilder, String connectionString, Action`1 sqlServerOptionsAction)
at ProjectX.Startup.<ConfigureServices>b__4_0(DbContextOptionsBuilder options) in C:\VSO\Avvenire Source\Internal\Project X\ProjectX\Startup.cs:line 35
... truncated for brevity ...
解决后,应用程序运行完美!
另外,请记住(在IIS上托管MVC Core应用程序时)相应地更新Program.cs文件:
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
}
最后,但并非最不重要的是,我需要通过添加新创建的SQL用户来修复连接字符串(它不能简单地使用集成安全性):
"ConnectionStrings": {
"DefaultConnection": "Server={theserver};Database={thedatabase};MultipleActiveResultSets=true;User Id={theusername};Password={thepassword};"
},