部署ASP.NET Core Web应用程序时,会遇到很多错误。如果您是中文的.NET。最好是翻译成英文。在谷歌或必应去搜索相关错误。中文搜索引擎你是什么都找不到的。这里整理了官方发布的错误信息及解决办法。是英文的哦。为什么不翻译中文?我英语太渣了。如果有人愿意免费翻译的话,请加我的QQ:301109552并注明来意(很多卖茶叶的、炒石油的加我。不堪其扰)。我会更新这篇文章的中英文对照版本并标注您的各种号码。


Installer unable to obtain VC++ Redistributable

  • Installer Exception: Installation of the .NET Core Windows Server Hosting Bundle fails with0x80070002 - The system cannot find the file specified.

Troubleshooting:

  • If the server does not have Internet access while installing the server hosting bundle, this exception will ensue when the installer is prevented from obtaining the Microsoft Visual C++ 2015 Redistributable (x64) packages online. You may obtain an installer for the packages from the Microsoft Download Center.

Platform conflicts with RID

  • Browser: HTTP Error 502.5 - Process Failure

  • Application Log: - Application Error: Faulting module: KERNELBASE.dll Exception code: 0xe0434352 Faulting module path: C:\WINDOWS\system32\KERNELBASE.dll - IIS AspNetCore Module: Failed to start process with commandline ‘“dotnet” .\my_application.dll’ (portable app) or ‘“PATH\my_application.exe”’ (self-contained app), ErrorCode = ‘0x80004005’.

  • ASP.NET Core Module Log: Unhandled Exception: System.BadImageFormatException: Could not load file or assembly ‘teststandalone.dll’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

Troubleshooting:

  • If you published a self-contained application, confirm that you didn’t set a platform inbuildOptions of project.json that conflicts with the publishing RID. For example, do not specify a platform of x86 and publish with an RID of win81-x64 (dotnet publish -c Release -r win81-x64). The project will publish without warning or error but fail with the above logged exceptions on the server.

URI endpoint wrong or stopped website

  • Browser: ERR_CONNECTION_REFUSED

  • Application Log: No entry

  • ASP.NET Core Module Log: Log file not created

Troubleshooting:

  • Confirm you are using the correct URI endpoint for the application. Check your bindings.

  • Confirm that the IIS website is not in the Stopped state.

CoreWebEngine or W3SVC server features disabled

  • OS Exception: The IIS 7.0 CoreWebEngine and W3SVC features must be installed to use the Microsoft HTTP Platform Handler 1.x.

Troubleshooting:

  • Confirm that you have enabled the proper server role and features. See IIS Configuration.

Incorrect website physical path or application missing

  • Browser: 403 Forbidden: Access is denied –OR– 403.14 Forbidden: The Web server is configured to not list the contents of this directory.

  • Application Log: No entry

  • ASP.NET Core Module Log: Log file not created

Troubleshooting:

  • Check the IIS website Basic Settings and the physical application assets folder. Confirm that the application is in the folder at the IIS website Physical path.

Incorrect server role, module not installed, or incorrect permissions

  • Browser: 500.19 Internal Server Error: The requested page cannot be accessed because the related configuration data for the page is invalid.

  • Application Log: No entry

  • ASP.NET Core Module Log: Log file not created

Troubleshooting:

  • Confirm that you have enabled the proper server role. See IIS Configuration.

  • Check Programs & Features and confirm that the Microsoft ASP.NET Core Module has been installed. If the Microsoft ASP.NET Core Module is not present in the list of installed programs, install the module. See IIS Configuration.

  • Make sure that the Application Pool Process Model Identity is either set toApplicationPoolIdentity; or if a custom identity is in use, confirm the identity has the correct permissions to access the application’s assets folder.

Hosting bundle not installed or server not restarted

  • Browser: 502.3 Bad Gateway: There was a connection error while trying to route the request.

  • Application Log: Process ‘0’ failed to start. Port = PORT, Error Code = ‘-2147024894’.

  • ASP.NET Core Module Log: Log file created but empty

Troubleshooting:

  • You may have deployed a portable application without installing .NET Core on the server. If you are attempting to deploy a portable application and have not installed .NET Core, run the .NET Core Windows Server Hosting Bundle Installer on the server. See Install the .NET Core Windows Server Hosting Bundle.

  • You may have deployed a portable application and installed .NET Core without restarting the server. Restart the server.

Incorrect proecessPath, missing PATH variable, or dotnet.exe access violation

  • Browser: HTTP Error 502.5 - Process Failure

  • Application Log: Failed to start process with commandline ‘“dotnet” .\my_application.dll’ (portable app) or ‘”.\my_application_Foo.exe”’ (self-contained app), ErrorCode = ‘0x80070002’.

  • ASP.NET Core Module Log: Log file created but empty

Troubleshooting:

  • Check the processPath attribute on the <aspNetCore> element in web.config to confirm that it is dotnet for a portable application or .\my_application.exe for a self-contained application.

  • For a portable application, dotnet.exe might not be accessible via the PATH settings. Confirm that C:\Program Files\dotnet\ exists in the System PATH settings.

  • For a portable application, dotnet.exe might not be accessible for the user identity of the Application Pool. Confirm that the AppPool user identity has access to the C:\Program Files\dotnet directory.

Incorrect arguments of <aspNetCore> element

  • Browser: HTTP Error 502.5 - Process Failure

  • Application Log: Failed to start process with commandline ‘“dotnet” .\my_application_Foo.dll’, ErrorCode = ‘0x80004005’.

  • ASP.NET Core Module Log: The application to execute does not exist: ‘PATH\my_application_Foo.dll’

Troubleshooting:

  • Examine the arguments attribute on the <aspNetCore> element in web.config to confirm that it is either (a) .\my_applciation.dll for a portable application; or (b) not present, an empty string (arguments=”“), or a list of your application’s arguments (arguments=”arg1, arg2, ...”) for a self-contained application.

Missing .NET Framework version

  • Browser: 502.3 Bad Gateway: There was a connection error while trying to route the request.

  • Application Log: Failed to start process with commandline ‘[IIS_WEBSITE_PHYSICAL_PATH] ‘, Error Code = ‘0x80004005’.

  • ASP.NET Core Module Log: Missing method, file, or assembly exception. The method, file, or assembly specified in the exception is a .NET Framework method, file, or assembly.

Troubleshooting:

  • Install the .NET Framework version missing from the server.

Stopped Application Pool

  • Browser: 503 Service Unavailable

  • Application Log: No entry

  • ASP.NET Core Module Log: Log file not created

Troubleshooting

  • Confirm that the Application Pool is not in the Stopped state.

IIS Integration middleware not implemented or .UseUrls() after .UseIISIntegration()

  • Browser: HTTP Error 502.5 - Process Failure

  • Application Log: Process was created with commandline ‘“dotnet” .\my_application.dll’ (portable app) or ‘”.\my_application.exe”’ (self-contained app) but either crashed or did not reponse within given time or did not listen on the given port ‘PORT’, ErrorCode = ‘0x800705b4’

  • ASP.NET Core Module Log: Log file created and shows normal operation.

Troubleshooting

  • Confirm that you have correctly referenced the IIS Integration middleware by calling the.UseIISIntegration() method of the application’s WebHostBuilder().

  • If you are using the .UseUrls() extension method when self-hosting with Kestrel, confirm that it is positioned before the .UseIISIntegration() extension method on WebHostBuilder()..UseIISIntegration() must set the Url for the reverse-proxy when running Kestrel behind IIS and not have its value overridden by .UseUrls().