Događaj
Power BI DataViz Svetsko prvenstvo
14. feb 16 - 31. mar 16
Sa 4 šanse za ulazak, možete osvojiti konferencijski paket i stići do LIVE Grand Finale u Las Vegasu
Saznajte višeOvaj pregledač više nije podržan.
Nadogradite na Microsoft Edge biste iskoristili najnovije funkcije, bezbednosne ispravke i tehničku podršku.
This article provides information on common app startup errors and instructions on how to diagnose errors when an app is deployed to Azure App Service or IIS:
App startup errors
Explains common startup HTTP status code scenarios.
Troubleshoot on Azure App Service
Provides troubleshooting advice for apps deployed to Azure App Service.
Troubleshoot on IIS
Provides troubleshooting advice for apps deployed to IIS or running on IIS Express locally. The guidance applies to both Windows Server and Windows desktop deployments.
Clear package caches
Explains what to do when incoherent packages break an app when performing major upgrades or changing package versions.
Additional resources
Lists additional troubleshooting topics.
In Visual Studio, the ASP.NET Core project default server is Kestrel. Visual studio can be configured to use IIS Express. A 502.5 - Process Failure or a 500.30 - Start Failure that occurs when debugging locally with IIS Express can be diagnosed using the advice in this topic.
The app fails to start. The following error is logged:
The Web server is configured to not list the contents of this directory.
The error is usually caused by a broken deployment on the hosting system, which includes any of the following scenarios:
Perform the following steps:
D:\home\site\wwwroot
folder.For more information on the layout of a published ASP.NET Core app, see ASP.NET Core directory structure. For more information on the web.config file, see ASP.NET Core Module (ANCM) for IIS.
The app starts, but an error prevents the server from fulfilling the request.
This error occurs within the app's code during startup or while creating a response. The response may contain no content, or the response may appear as a 500 Internal Server Error in the browser. The Application Event Log usually states that the app started normally. From the server's perspective, that's correct. The app did start, but it can't generate a valid response. Run the app at a command prompt on the server or enable the ASP.NET Core Module stdout log to troubleshoot the problem.
This error also may occur when the .NET Core Hosting Bundle isn't installed or is corrupted. Installing or repairing the installation of the .NET Core Hosting Bundle (for IIS) or Visual Studio (for IIS Express) may fix the problem.
The worker process fails. The app doesn't start.
An unknown error occurred loading ASP.NET Core Module components. Take one of the following actions:
The worker process fails. The app doesn't start.
The ASP.NET Core Module attempts to start the .NET Core CLR in-process, but it fails to start. The cause of a process startup failure can usually be determined from entries in the Application Event Log and the ASP.NET Core Module stdout log.
Common failure conditions:
The worker process fails. The app doesn't start.
The ASP.NET Core Module attempts to start the .NET Core runtime in-process, but it fails to start. The most common cause of this startup failure is when the Microsoft.NETCore.App
or Microsoft.AspNetCore.App
runtime isn't installed. If the app is deployed to target ASP.NET Core 3.0 and that version doesn't exist on the machine, this error occurs. An example error message follows:
The specified framework 'Microsoft.NETCore.App', version '3.0.0' was not found.
- The following frameworks were found:
2.2.1 at [C:\Program Files\dotnet\x64\shared\Microsoft.NETCore.App]
3.0.0-preview5-27626-15 at [C:\Program Files\dotnet\x64\shared\Microsoft.NETCore.App]
3.0.0-preview6-27713-13 at [C:\Program Files\dotnet\x64\shared\Microsoft.NETCore.App]
3.0.0-preview6-27714-15 at [C:\Program Files\dotnet\x64\shared\Microsoft.NETCore.App]
3.0.0-preview6-27723-08 at [C:\Program Files\dotnet\x64\shared\Microsoft.NETCore.App]
The error message lists all the installed .NET Core versions and the version requested by the app. To fix this error, either:
When running in development (the ASPNETCORE_ENVIRONMENT
environment variable is set to Development
), the specific error is written to the HTTP response. The cause of a process startup failure is also found in the Application Event Log.
The worker process fails. The app doesn't start.
The most common cause for this error is that the app is published for an incompatible processor architecture. If the worker process is running as a 32-bit app and the app was published to target 64-bit, this error occurs.
To fix this error, either:
The worker process fails. The app doesn't start.
The app didn't reference the Microsoft.AspNetCore.App
framework. Only apps targeting the Microsoft.AspNetCore.App
framework can be hosted by the ASP.NET Core Module.
To fix this error, confirm that the app is targeting the Microsoft.AspNetCore.App
framework. Check the .runtimeconfig.json
to verify the framework targeted by the app.
The worker process can't run both an in-process app and an out-of-process app in the same process.
To fix this error, run apps in separate IIS application pools.
The worker process can't run multiple in-process apps in the same process.
To fix this error, run apps in separate IIS application pools.
The out-of-process request handler, aspnetcorev2_outofprocess.dll, isn't next to the aspnetcorev2.dll file. This indicates a corrupted installation of the ASP.NET Core Module.
To fix this error, repair the installation of the .NET Core Hosting Bundle (for IIS) or Visual Studio (for IIS Express).
ANCM failed to start within the provided startup time limit. By default, the timeout is 120 seconds.
This error can occur when starting a large number of apps on the same machine. Check for CPU/Memory usage spikes on the server during startup. You may need to stagger the startup process of multiple apps.
ANCM failed to locate the application DLL, which should be next to the executable.
This error occurs when hosting an app packaged as a single-file executable using the in-process hosting model. The in-process model requires that the ANCM load the .NET Core app into the existing IIS process. This scenario isn't supported by the single-file deployment model. Use one of the following approaches in the app's project file to fix this error:
PublishSingleFile
MSBuild property to false
.AspNetCoreHostingModel
MSBuild property to OutOfProcess
.The worker process fails. The app doesn't start.
The ASP.NET Core Module attempts to start the worker process but it fails to start. The cause of a process startup failure can usually be determined from entries in the Application Event Log and the ASP.NET Core Module stdout log.
A common failure condition is the app is misconfigured due to targeting a version of the ASP.NET Core shared framework that isn't present. Check which versions of the ASP.NET Core shared framework are installed on the target machine. The shared framework is the set of assemblies (.dll files) that are installed on the machine and referenced by a metapackage such as Microsoft.AspNetCore.App
. The metapackage reference can specify a minimum required version. For more information, see The shared framework.
The 502.5 Process Failure error page is returned when a hosting or app misconfiguration causes the worker process to fail:
EventID: 1010
Source: IIS AspNetCore Module V2
Failed to start application '/LM/W3SVC/6/ROOT/', ErrorCode '0x800700c1'.
The app failed to start because the app's assembly (.dll) couldn't be loaded.
This error occurs when there's a bitness mismatch between the published app and the w3wp/iisexpress process.
Confirm that the app pool's 32-bit setting is correct:
True
.False
.Confirm that there isn't a conflict between a <Platform>
MSBuild property in the project file and the published bitness of the app.
EventID: 1010
Source: IIS AspNetCore Module V2
Failed to start application '/LM/W3SVC/3/ROOT', ErrorCode '0x800701b1'.
The app failed to start because a Windows Service failed to load.
One common service that needs to be enabled is the "null" service.
The following command enables the null
Windows Service:
sc.exe start null
If an error occurs after the headers are sent, it's too late for the server to send a 500 Internal Server Error when an error occurs. This often happens when an error occurs during the serialization of complex objects for a response. This type of error appears as a connection reset error on the client. Application logging can help troubleshoot these types of errors.
The ASP.NET Core Module is configured with a default startupTimeLimit of 120 seconds. When left at the default value, an app may take up to two minutes to start before the module logs a process failure. For information on configuring the module, see Attributes of the aspNetCore element.
Važno
ASP.NET Core preview releases with Azure App Service
ASP.NET Core preview releases aren't deployed to Azure App Service by default. To host an app that uses an ASP.NET Core preview release, see Deploy ASP.NET Core preview release to Azure App Service.
The Azure App Services Log streams logging information as it occurs. To view streaming logs:
The following images shows the application logs output:
Streaming logs have some latency and might not display immediately.
To access the Application Event Log, use the Diagnose and solve problems blade in the Azure portal:
An alternative to using the Diagnose and solve problems blade is to examine the Application Event Log file directly using Kudu:
eventlog.xml
file.Many startup errors don't produce useful information in the Application Event Log. You can run the app in the Kudu Remote Execution Console to discover the error:
Current release
cd d:\home\site\wwwroot
If the app is a framework-dependent deployment:
dotnet .\{ASSEMBLY NAME}.dll
If the app is a self-contained deployment:
{ASSEMBLY NAME}.exe
The console output from the app, showing any errors, is piped to the Kudu console.
Framework-dependent deployment running on a preview release
Requires installing the ASP.NET Core {VERSION} (x86) Runtime site extension.
cd D:\home\SiteExtensions\AspNetCoreRuntime.{X.Y}.x32
({X.Y}
is the runtime version)dotnet \home\site\wwwroot\{ASSEMBLY NAME}.dll
The console output from the app, showing any errors, is piped to the Kudu console.
Current release
cd D:\Program Files\dotnet
dotnet \home\site\wwwroot\{ASSEMBLY NAME}.dll
cd D:\home\site\wwwroot
{ASSEMBLY NAME}.exe
The console output from the app, showing any errors, is piped to the Kudu console.
Framework-dependent deployment running on a preview release
Requires installing the ASP.NET Core {VERSION} (x64) Runtime site extension.
cd D:\home\SiteExtensions\AspNetCoreRuntime.{X.Y}.x64
({X.Y}
is the runtime version)dotnet \home\site\wwwroot\{ASSEMBLY NAME}.dll
The console output from the app, showing any errors, is piped to the Kudu console.
Upozorenje
Failure to disable the stdout log can lead to app or server failure. There's no limit on log file size or the number of log files created. Only use stdout logging to troubleshoot app startup problems.
For general logging in an ASP.NET Core app after startup, use a logging library that limits log file size and rotates logs. For more information, see third-party logging providers.
The ASP.NET Core Module stdout log often records useful error messages not found in the Application Event Log. To enable and view stdout logs:
<aspNetCore />
element, set stdoutLogEnabled="true"
and select Save.Disable stdout logging when troubleshooting is complete by setting stdoutLogEnabled="false"
.
For more information, see ASP.NET Core Module (ANCM) for IIS.
The ASP.NET Core Module debug log provides additional, deeper logging from the ASP.NET Core Module. To enable and view stdout logs:
<handlerSettings>
shown in Enhanced diagnostic logs to the live app's web.config file using the Kudu console:
<handlerSettings>
section as shown in Enhanced diagnostic logs. Select the Save button.Disable debug logging when troubleshooting is complete:
To disable the enhanced debug log, perform either of the following:
<handlerSettings>
from the web.config file locally and redeploy the app.<handlerSettings>
section. Save the file.For more information, see Log creation and redirection with the ASP.NET Core Module.
Upozorenje
Failure to disable the debug log can lead to app or server failure. There's no limit on log file size. Only use debug logging to troubleshoot app startup problems.
For general logging in an ASP.NET Core app after startup, use a logging library that limits log file size and rotates logs. For more information, see third-party logging providers.
When an app responds slowly or doesn't respond to a request, see Troubleshoot slow web app performance issues in Azure App Service.
Monitoring blades provide an alternative troubleshooting experience to the methods described earlier in the topic. These blades can be used to diagnose 500-series errors.
Confirm that the ASP.NET Core Extensions are installed. If the extensions aren't installed, install them manually:
If stdout logging isn't enabled, follow these steps:
true
and change the stdoutLogFile path to: \\?\%home%\LogFiles\stdout
.Proceed to activate diagnostic logging:
Be sure to disable stdout logging when troubleshooting is complete.
To view the failed request tracing logs (FREB logs):
See Failed request traces section of the Enable diagnostics logging for web apps in Azure App Service topic and the Application performance FAQs for Web Apps in Azure: How do I turn on failed request tracing? for more information.
For more information, see Enable diagnostics logging for web apps in Azure App Service.
Upozorenje
Failure to disable the stdout log can lead to app or server failure. There's no limit on log file size or the number of log files created.
For routine logging in an ASP.NET Core app, use a logging library that limits log file size and rotates logs. For more information, see third-party logging providers.
Access the Application Event Log:
Many startup errors don't produce useful information in the Application Event Log. You can find the cause of some errors by running the app at a command prompt on the hosting system.
If the app is a framework-dependent deployment:
dotnet .\<assembly_name>.dll
.http://localhost:5000/
. If the app responds normally at the Kestrel endpoint address, the problem is more likely related to the hosting configuration and less likely within the app.If the app is a self-contained deployment:
<assembly_name>.exe
.http://localhost:5000/
. If the app responds normally at the Kestrel endpoint address, the problem is more likely related to the hosting configuration and less likely within the app.To enable and view stdout logs:
true
and change the stdoutLogFile path to point to the logs folder (for example, .\logs\stdout
). stdout
in the path is the log file name prefix. A timestamp, process id, and file extension are added automatically when the log is created. Using stdout
as the file name prefix, a typical log file is named stdout_20180205184032_5412.log.Disable stdout logging when troubleshooting is complete:
false
.For more information, see ASP.NET Core Module (ANCM) for IIS.
Upozorenje
Failure to disable the stdout log can lead to app or server failure. There's no limit on log file size or the number of log files created.
For routine logging in an ASP.NET Core app, use a logging library that limits log file size and rotates logs. For more information, see third-party logging providers.
Add the following handler settings to the app's web.config file to enable ASP.NET Core Module debug log:
<aspNetCore ...>
<handlerSettings>
<handlerSetting name="debugLevel" value="file" />
<handlerSetting name="debugFile" value="c:\temp\ancm.log" />
</handlerSettings>
</aspNetCore>
Confirm that the path specified for the log exists and that the app pool's identity has write permissions to the location.
For more information, see Log creation and redirection with the ASP.NET Core Module.
The ASPNETCORE_ENVIRONMENT
environment variable can be added to web.config to run the app in the Development environment. As long as the environment isn't overridden in app startup by UseEnvironment
on the host builder, setting the environment variable allows the Developer Exception Page to appear when the app is run.
<aspNetCore processPath="dotnet"
arguments=".\MyApp.dll"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout"
hostingModel="InProcess">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
Setting the environment variable for ASPNETCORE_ENVIRONMENT
is only recommended for use on staging and testing servers that aren't exposed to the Internet. Remove the environment variable from the web.config file after troubleshooting. For information on setting environment variables in web.config, see environmentVariables child element of aspNetCore.
If an app is capable of responding to requests, obtain request, connection, and additional data from the app using terminal inline middleware. For more information and sample code, see Troubleshoot and debug ASP.NET Core projects.
A crash dump is a snapshot of the system's memory and can help determine the cause of an app crash, startup failure, or slow app.
Obtain and analyze a dump from Windows Error Reporting (WER):
Create a folder to hold crash dump files at c:\dumps
. The app pool must have write access to the folder.
Run the EnableDumps PowerShell script:
If the app uses the in-process hosting model, run the script for w3wp.exe:
.\EnableDumps w3wp.exe c:\dumps
If the app uses the out-of-process hosting model, run the script for dotnet.exe:
.\EnableDumps dotnet.exe c:\dumps
Run the app under the conditions that cause the crash to occur.
After the crash has occurred, run the DisableDumps PowerShell script:
If the app uses the in-process hosting model, run the script for w3wp.exe:
.\DisableDumps w3wp.exe
If the app uses the out-of-process hosting model, run the script for dotnet.exe:
.\DisableDumps dotnet.exe
After an app crashes and dump collection is complete, the app is allowed to terminate normally. The PowerShell script configures WER to collect up to five dumps per app.
Upozorenje
Crash dumps might take up a large amount of disk space (up to several gigabytes each).
When an app stops responding but doesn't crash, fails during startup, or runs normally, see User-Mode Dump Files: Choosing the Best Tool to select an appropriate tool to produce the dump.
A dump can be analyzed using several approaches. For more information, see Analyzing a User-Mode Dump File.
A functioning app may fail immediately after upgrading either the .NET Core SDK on the development machine or changing package versions within the app. In some cases, incoherent packages may break an app when performing major upgrades. Most of these issues can be fixed by following these instructions:
Delete the bin and obj folders.
Clear the package caches by executing dotnet nuget locals all --clear from a command shell.
Clearing package caches can also be accomplished with the nuget.exe tool and executing the command nuget locals all -clear
. nuget.exe isn't a bundled install with the Windows desktop operating system and must be obtained separately from the NuGet website.
Restore and rebuild the project.
Delete all of the files in the deployment folder on the server prior to redeploying the app.
This article provides information on common app startup errors and instructions on how to diagnose errors when an app is deployed to Azure App Service or IIS:
App startup errors
Explains common startup HTTP status code scenarios.
Troubleshoot on Azure App Service
Provides troubleshooting advice for apps deployed to Azure App Service.
Troubleshoot on IIS
Provides troubleshooting advice for apps deployed to IIS or running on IIS Express locally. The guidance applies to both Windows Server and Windows desktop deployments.
Clear package caches
Explains what to do when incoherent packages break an app when performing major upgrades or changing package versions.
Additional resources
Lists additional troubleshooting topics.
In Visual Studio, an ASP.NET Core project defaults to IIS Express hosting during debugging. A 502.5 - Process Failure or a 500.30 - Start Failure that occurs when debugging locally can be diagnosed using the advice in this topic.
The app fails to start. The following error is logged:
The Web server is configured to not list the contents of this directory.
The error is usually caused by a broken deployment on the hosting system, which includes any of the following scenarios:
Perform the following steps:
D:\home\site\wwwroot
folder.For more information on the layout of a published ASP.NET Core app, see ASP.NET Core directory structure. For more information on the web.config file, see ASP.NET Core Module (ANCM) for IIS.
The app starts, but an error prevents the server from fulfilling the request.
This error occurs within the app's code during startup or while creating a response. The response may contain no content, or the response may appear as a 500 Internal Server Error in the browser. The Application Event Log usually states that the app started normally. From the server's perspective, that's correct. The app did start, but it can't generate a valid response. Run the app at a command prompt on the server or enable the ASP.NET Core Module stdout log to troubleshoot the problem.
This error also may occur when the .NET Core Hosting Bundle isn't installed or is corrupted. Installing or repairing the installation of the .NET Core Hosting Bundle (for IIS) or Visual Studio (for IIS Express) may fix the problem.
The worker process fails. The app doesn't start.
The ASP.NET Core Module fails to find the .NET Core CLR and find the in-process request handler (aspnetcorev2_inprocess.dll). Check that:
The worker process fails. The app doesn't start.
The ASP.NET Core Module fails to find the out-of-process hosting request handler. Make sure the aspnetcorev2_outofprocess.dll is present in a subfolder next to aspnetcorev2.dll.
The worker process fails. The app doesn't start.
The ASP.NET Core Module attempts to start the worker process but it fails to start. The cause of a process startup failure can usually be determined from entries in the Application Event Log and the ASP.NET Core Module stdout log.
A common failure condition is the app is misconfigured due to targeting a version of the ASP.NET Core shared framework that isn't present. Check which versions of the ASP.NET Core shared framework are installed on the target machine. The shared framework is the set of assemblies (.dll files) that are installed on the machine and referenced by a metapackage such as Microsoft.AspNetCore.App
. The metapackage reference can specify a minimum required version. For more information, see The shared framework.
The 502.5 Process Failure error page is returned when a hosting or app misconfiguration causes the worker process to fail:
EventID: 1010
Source: IIS AspNetCore Module V2
Failed to start application '/LM/W3SVC/6/ROOT/', ErrorCode '0x800700c1'.
The app failed to start because the app's assembly (.dll) couldn't be loaded.
This error occurs when there's a bitness mismatch between the published app and the w3wp/iisexpress process.
Confirm that the app pool's 32-bit setting is correct:
True
.False
.Confirm that there isn't a conflict between a <Platform>
MSBuild property in the project file and the published bitness of the app.
If an error occurs after the headers are sent, it's too late for the server to send a 500 Internal Server Error when an error occurs. This often happens when an error occurs during the serialization of complex objects for a response. This type of error appears as a connection reset error on the client. Application logging can help troubleshoot these types of errors.
The ASP.NET Core Module is configured with a default startupTimeLimit of 120 seconds. When left at the default value, an app may take up to two minutes to start before the module logs a process failure. For information on configuring the module, see Attributes of the aspNetCore element.
Važno
ASP.NET Core preview releases with Azure App Service
ASP.NET Core preview releases aren't deployed to Azure App Service by default. To host an app that uses an ASP.NET Core preview release, see Deploy ASP.NET Core preview release to Azure App Service.
To access the Application Event Log, use the Diagnose and solve problems blade in the Azure portal:
An alternative to using the Diagnose and solve problems blade is to examine the Application Event Log file directly using Kudu:
eventlog.xml
file.Many startup errors don't produce useful information in the Application Event Log. You can run the app in the Kudu Remote Execution Console to discover the error:
Current release
cd d:\home\site\wwwroot
If the app is a framework-dependent deployment:
dotnet .\{ASSEMBLY NAME}.dll
If the app is a self-contained deployment:
{ASSEMBLY NAME}.exe
The console output from the app, showing any errors, is piped to the Kudu console.
Framework-dependent deployment running on a preview release
Requires installing the ASP.NET Core {VERSION} (x86) Runtime site extension.
cd D:\home\SiteExtensions\AspNetCoreRuntime.{X.Y}.x32
({X.Y}
is the runtime version)dotnet \home\site\wwwroot\{ASSEMBLY NAME}.dll
The console output from the app, showing any errors, is piped to the Kudu console.
Current release
cd D:\Program Files\dotnet
dotnet \home\site\wwwroot\{ASSEMBLY NAME}.dll
cd D:\home\site\wwwroot
{ASSEMBLY NAME}.exe
The console output from the app, showing any errors, is piped to the Kudu console.
Framework-dependent deployment running on a preview release
Requires installing the ASP.NET Core {VERSION} (x64) Runtime site extension.
cd D:\home\SiteExtensions\AspNetCoreRuntime.{X.Y}.x64
({X.Y}
is the runtime version)dotnet \home\site\wwwroot\{ASSEMBLY NAME}.dll
The console output from the app, showing any errors, is piped to the Kudu console.
The ASP.NET Core Module stdout log often records useful error messages not found in the Application Event Log. To enable and view stdout logs:
true
and change the stdoutLogFile path to: \\?\%home%\LogFiles\stdout
.Disable stdout logging when troubleshooting is complete:
false
.For more information, see ASP.NET Core Module (ANCM) for IIS.
Upozorenje
Failure to disable the stdout log can lead to app or server failure. There's no limit on log file size or the number of log files created. Only use stdout logging to troubleshoot app startup problems.
For general logging in an ASP.NET Core app after startup, use a logging library that limits log file size and rotates logs. For more information, see third-party logging providers.
The ASP.NET Core Module debug log provides additional, deeper logging from the ASP.NET Core Module. To enable and view stdout logs:
<handlerSettings>
shown in Enhanced diagnostic logs to the live app's web.config file using the Kudu console:
<handlerSettings>
section as shown in Enhanced diagnostic logs. Select the Save button.Disable debug logging when troubleshooting is complete:
To disable the enhanced debug log, perform either of the following:
<handlerSettings>
from the web.config file locally and redeploy the app.<handlerSettings>
section. Save the file.For more information, see Log creation and redirection with the ASP.NET Core Module.
Upozorenje
Failure to disable the debug log can lead to app or server failure. There's no limit on log file size. Only use debug logging to troubleshoot app startup problems.
For general logging in an ASP.NET Core app after startup, use a logging library that limits log file size and rotates logs. For more information, see third-party logging providers.
When an app responds slowly or doesn't respond to a request, see the following articles:
Monitoring blades provide an alternative troubleshooting experience to the methods described earlier in the topic. These blades can be used to diagnose 500-series errors.
Confirm that the ASP.NET Core Extensions are installed. If the extensions aren't installed, install them manually:
If stdout logging isn't enabled, follow these steps:
true
and change the stdoutLogFile path to: \\?\%home%\LogFiles\stdout
.Proceed to activate diagnostic logging:
Be sure to disable stdout logging when troubleshooting is complete.
To view the failed request tracing logs (FREB logs):
See Failed request traces section of the Enable diagnostics logging for web apps in Azure App Service topic and the Application performance FAQs for Web Apps in Azure: How do I turn on failed request tracing? for more information.
For more information, see Enable diagnostics logging for web apps in Azure App Service.
Upozorenje
Failure to disable the stdout log can lead to app or server failure. There's no limit on log file size or the number of log files created.
For routine logging in an ASP.NET Core app, use a logging library that limits log file size and rotates logs. For more information, see third-party logging providers.
Access the Application Event Log:
Many startup errors don't produce useful information in the Application Event Log. You can find the cause of some errors by running the app at a command prompt on the hosting system.
If the app is a framework-dependent deployment:
dotnet .\<assembly_name>.dll
.http://localhost:5000/
. If the app responds normally at the Kestrel endpoint address, the problem is more likely related to the hosting configuration and less likely within the app.If the app is a self-contained deployment:
<assembly_name>.exe
.http://localhost:5000/
. If the app responds normally at the Kestrel endpoint address, the problem is more likely related to the hosting configuration and less likely within the app.To enable and view stdout logs:
true
and change the stdoutLogFile path to point to the logs folder (for example, .\logs\stdout
). stdout
in the path is the log file name prefix. A timestamp, process id, and file extension are added automatically when the log is created. Using stdout
as the file name prefix, a typical log file is named stdout_20180205184032_5412.log.Disable stdout logging when troubleshooting is complete:
false
.For more information, see ASP.NET Core Module (ANCM) for IIS.
Upozorenje
Failure to disable the stdout log can lead to app or server failure. There's no limit on log file size or the number of log files created.
For routine logging in an ASP.NET Core app, use a logging library that limits log file size and rotates logs. For more information, see third-party logging providers.
Add the following handler settings to the app's web.config file to enable ASP.NET Core Module debug log:
<aspNetCore ...>
<handlerSettings>
<handlerSetting name="debugLevel" value="file" />
<handlerSetting name="debugFile" value="c:\temp\ancm.log" />
</handlerSettings>
</aspNetCore>
Confirm that the path specified for the log exists and that the app pool's identity has write permissions to the location.
For more information, see Log creation and redirection with the ASP.NET Core Module.
The ASPNETCORE_ENVIRONMENT
environment variable can be added to web.config to run the app in the Development environment. As long as the environment isn't overridden in app startup by UseEnvironment
on the host builder, setting the environment variable allows the Developer Exception Page to appear when the app is run.
<aspNetCore processPath="dotnet"
arguments=".\MyApp.dll"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout"
hostingModel="InProcess">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
Setting the environment variable for ASPNETCORE_ENVIRONMENT
is only recommended for use on staging and testing servers that aren't exposed to the Internet. Remove the environment variable from the web.config file after troubleshooting. For information on setting environment variables in web.config, see environmentVariables child element of aspNetCore.
If an app is capable of responding to requests, obtain request, connection, and additional data from the app using terminal inline middleware. For more information and sample code, see Troubleshoot and debug ASP.NET Core projects.
A crash dump is a snapshot of the system's memory and can help determine the cause of an app crash, startup failure, or slow app.
Obtain and analyze a dump from Windows Error Reporting (WER):
Create a folder to hold crash dump files at c:\dumps
. The app pool must have write access to the folder.
Run the EnableDumps PowerShell script:
If the app uses the in-process hosting model, run the script for w3wp.exe:
.\EnableDumps w3wp.exe c:\dumps
If the app uses the out-of-process hosting model, run the script for dotnet.exe:
.\EnableDumps dotnet.exe c:\dumps
Run the app under the conditions that cause the crash to occur.
After the crash has occurred, run the DisableDumps PowerShell script:
If the app uses the in-process hosting model, run the script for w3wp.exe:
.\DisableDumps w3wp.exe
If the app uses the out-of-process hosting model, run the script for dotnet.exe:
.\DisableDumps dotnet.exe
After an app crashes and dump collection is complete, the app is allowed to terminate normally. The PowerShell script configures WER to collect up to five dumps per app.
Upozorenje
Crash dumps might take up a large amount of disk space (up to several gigabytes each).
When an app stops responding but doesn't crash, fails during startup, or runs normally, see User-Mode Dump Files: Choosing the Best Tool to select an appropriate tool to produce the dump.
A dump can be analyzed using several approaches. For more information, see Analyzing a User-Mode Dump File.
A functioning app may fail immediately after upgrading either the .NET Core SDK on the development machine or changing package versions within the app. In some cases, incoherent packages may break an app when performing major upgrades. Most of these issues can be fixed by following these instructions:
Delete the bin and obj folders.
Clear the package caches by executing dotnet nuget locals all --clear from a command shell.
Clearing package caches can also be accomplished with the nuget.exe tool and executing the command nuget locals all -clear
. nuget.exe isn't a bundled install with the Windows desktop operating system and must be obtained separately from the NuGet website.
Restore and rebuild the project.
Delete all of the files in the deployment folder on the server prior to redeploying the app.
This article provides information on common app startup errors and instructions on how to diagnose errors when an app is deployed to Azure App Service or IIS:
App startup errors
Explains common startup HTTP status code scenarios.
Troubleshoot on Azure App Service
Provides troubleshooting advice for apps deployed to Azure App Service.
Troubleshoot on IIS
Provides troubleshooting advice for apps deployed to IIS or running on IIS Express locally. The guidance applies to both Windows Server and Windows desktop deployments.
Clear package caches
Explains what to do when incoherent packages break an app when performing major upgrades or changing package versions.
Additional resources
Lists additional troubleshooting topics.
In Visual Studio, an ASP.NET Core project defaults to IIS Express hosting during debugging. A 502.5 Process Failure that occurs when debugging locally can be diagnosed using the advice in this topic.
The app fails to start. The following error is logged:
The Web server is configured to not list the contents of this directory.
The error is usually caused by a broken deployment on the hosting system, which includes any of the following scenarios:
Perform the following steps:
D:\home\site\wwwroot
folder.For more information on the layout of a published ASP.NET Core app, see ASP.NET Core directory structure. For more information on the web.config file, see ASP.NET Core Module (ANCM) for IIS.
The app starts, but an error prevents the server from fulfilling the request.
This error occurs within the app's code during startup or while creating a response. The response may contain no content, or the response may appear as a 500 Internal Server Error in the browser. The Application Event Log usually states that the app started normally. From the server's perspective, that's correct. The app did start, but it can't generate a valid response. Run the app at a command prompt on the server or enable the ASP.NET Core Module stdout log to troubleshoot the problem.
This error also may occur when the .NET Core Hosting Bundle isn't installed or is corrupted. Installing or repairing the installation of the .NET Core Hosting Bundle (for IIS) or Visual Studio (for IIS Express) may fix the problem.
The worker process fails. The app doesn't start.
The ASP.NET Core Module attempts to start the worker process but it fails to start. The cause of a process startup failure can usually be determined from entries in the Application Event Log and the ASP.NET Core Module stdout log.
A common failure condition is the app is misconfigured due to targeting a version of the ASP.NET Core shared framework that isn't present. Check which versions of the ASP.NET Core shared framework are installed on the target machine. The shared framework is the set of assemblies (.dll files) that are installed on the machine and referenced by a metapackage such as Microsoft.AspNetCore.App
. The metapackage reference can specify a minimum required version. For more information, see The shared framework.
The 502.5 Process Failure error page is returned when a hosting or app misconfiguration causes the worker process to fail:
EventID: 1010
Source: IIS AspNetCore Module V2
Failed to start application '/LM/W3SVC/6/ROOT/', ErrorCode '0x800700c1'.
The app failed to start because the app's assembly (.dll) couldn't be loaded.
This error occurs when there's a bitness mismatch between the published app and the w3wp/iisexpress process.
Confirm that the app pool's 32-bit setting is correct:
True
.False
.Confirm that there isn't a conflict between a <Platform>
MSBuild property in the project file and the published bitness of the app.
If an error occurs after the headers are sent, it's too late for the server to send a 500 Internal Server Error when an error occurs. This often happens when an error occurs during the serialization of complex objects for a response. This type of error appears as a connection reset error on the client. Application logging can help troubleshoot these types of errors.
The ASP.NET Core Module is configured with a default startupTimeLimit of 120 seconds. When left at the default value, an app may take up to two minutes to start before the module logs a process failure. For information on configuring the module, see Attributes of the aspNetCore element.
Važno
ASP.NET Core preview releases with Azure App Service
ASP.NET Core preview releases aren't deployed to Azure App Service by default. To host an app that uses an ASP.NET Core preview release, see Deploy ASP.NET Core preview release to Azure App Service.
To access the Application Event Log, use the Diagnose and solve problems blade in the Azure portal:
An alternative to using the Diagnose and solve problems blade is to examine the Application Event Log file directly using Kudu:
eventlog.xml
file.Many startup errors don't produce useful information in the Application Event Log. You can run the app in the Kudu Remote Execution Console to discover the error:
Current release
cd d:\home\site\wwwroot
If the app is a framework-dependent deployment:
dotnet .\{ASSEMBLY NAME}.dll
If the app is a self-contained deployment:
{ASSEMBLY NAME}.exe
The console output from the app, showing any errors, is piped to the Kudu console.
Framework-dependent deployment running on a preview release
Requires installing the ASP.NET Core {VERSION} (x86) Runtime site extension.
cd D:\home\SiteExtensions\AspNetCoreRuntime.{X.Y}.x32
({X.Y}
is the runtime version)dotnet \home\site\wwwroot\{ASSEMBLY NAME}.dll
The console output from the app, showing any errors, is piped to the Kudu console.
Current release
cd D:\Program Files\dotnet
dotnet \home\site\wwwroot\{ASSEMBLY NAME}.dll
cd D:\home\site\wwwroot
{ASSEMBLY NAME}.exe
The console output from the app, showing any errors, is piped to the Kudu console.
Framework-dependent deployment running on a preview release
Requires installing the ASP.NET Core {VERSION} (x64) Runtime site extension.
cd D:\home\SiteExtensions\AspNetCoreRuntime.{X.Y}.x64
({X.Y}
is the runtime version)dotnet \home\site\wwwroot\{ASSEMBLY NAME}.dll
The console output from the app, showing any errors, is piped to the Kudu console.
The ASP.NET Core Module stdout log often records useful error messages not found in the Application Event Log. To enable and view stdout logs:
true
and change the stdoutLogFile path to: \\?\%home%\LogFiles\stdout
.Disable stdout logging when troubleshooting is complete:
false
.For more information, see ASP.NET Core Module (ANCM) for IIS.
Upozorenje
Failure to disable the stdout log can lead to app or server failure. There's no limit on log file size or the number of log files created. Only use stdout logging to troubleshoot app startup problems.
For general logging in an ASP.NET Core app after startup, use a logging library that limits log file size and rotates logs. For more information, see third-party logging providers.
When an app responds slowly or doesn't respond to a request, see the following articles:
Monitoring blades provide an alternative troubleshooting experience to the methods described earlier in the topic. These blades can be used to diagnose 500-series errors.
Confirm that the ASP.NET Core Extensions are installed. If the extensions aren't installed, install them manually:
If stdout logging isn't enabled, follow these steps:
true
and change the stdoutLogFile path to: \\?\%home%\LogFiles\stdout
.Proceed to activate diagnostic logging:
Be sure to disable stdout logging when troubleshooting is complete.
To view the failed request tracing logs (FREB logs):
See Failed request traces section of the Enable diagnostics logging for web apps in Azure App Service topic and the Application performance FAQs for Web Apps in Azure: How do I turn on failed request tracing? for more information.
For more information, see Enable diagnostics logging for web apps in Azure App Service.
Upozorenje
Failure to disable the stdout log can lead to app or server failure. There's no limit on log file size or the number of log files created.
For routine logging in an ASP.NET Core app, use a logging library that limits log file size and rotates logs. For more information, see third-party logging providers.
Access the Application Event Log:
Many startup errors don't produce useful information in the Application Event Log. You can find the cause of some errors by running the app at a command prompt on the hosting system.
If the app is a framework-dependent deployment:
dotnet .\<assembly_name>.dll
.http://localhost:5000/
. If the app responds normally at the Kestrel endpoint address, the problem is more likely related to the hosting configuration and less likely within the app.If the app is a self-contained deployment:
<assembly_name>.exe
.http://localhost:5000/
. If the app responds normally at the Kestrel endpoint address, the problem is more likely related to the hosting configuration and less likely within the app.To enable and view stdout logs:
true
and change the stdoutLogFile path to point to the logs folder (for example, .\logs\stdout
). stdout
in the path is the log file name prefix. A timestamp, process id, and file extension are added automatically when the log is created. Using stdout
as the file name prefix, a typical log file is named stdout_20180205184032_5412.log.Disable stdout logging when troubleshooting is complete:
false
.For more information, see ASP.NET Core Module (ANCM) for IIS.
Upozorenje
Failure to disable the stdout log can lead to app or server failure. There's no limit on log file size or the number of log files created.
For routine logging in an ASP.NET Core app, use a logging library that limits log file size and rotates logs. For more information, see third-party logging providers.
The ASPNETCORE_ENVIRONMENT
environment variable can be added to web.config to run the app in the Development environment. As long as the environment isn't overridden in app startup by UseEnvironment
on the host builder, setting the environment variable allows the Developer Exception Page to appear when the app is run.
<aspNetCore processPath="dotnet"
arguments=".\MyApp.dll"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
Setting the environment variable for ASPNETCORE_ENVIRONMENT
is only recommended for use on staging and testing servers that aren't exposed to the Internet. Remove the environment variable from the web.config file after troubleshooting. For information on setting environment variables in web.config, see environmentVariables child element of aspNetCore.
If an app is capable of responding to requests, obtain request, connection, and additional data from the app using terminal inline middleware. For more information and sample code, see Troubleshoot and debug ASP.NET Core projects.
A crash dump is a snapshot of the system's memory and can help determine the cause of an app crash, startup failure, or slow app.
Obtain and analyze a dump from Windows Error Reporting (WER):
Create a folder to hold crash dump files at c:\dumps
. The app pool must have write access to the folder.
Run the EnableDumps PowerShell script:
If the app uses the in-process hosting model, run the script for w3wp.exe:
.\EnableDumps w3wp.exe c:\dumps
If the app uses the out-of-process hosting model, run the script for dotnet.exe:
.\EnableDumps dotnet.exe c:\dumps
Run the app under the conditions that cause the crash to occur.
After the crash has occurred, run the DisableDumps PowerShell script:
If the app uses the in-process hosting model, run the script for w3wp.exe:
.\DisableDumps w3wp.exe
If the app uses the out-of-process hosting model, run the script for dotnet.exe:
.\DisableDumps dotnet.exe
After an app crashes and dump collection is complete, the app is allowed to terminate normally. The PowerShell script configures WER to collect up to five dumps per app.
Upozorenje
Crash dumps might take up a large amount of disk space (up to several gigabytes each).
When an app stops responding but doesn't crash, fails during startup, or runs normally, see User-Mode Dump Files: Choosing the Best Tool to select an appropriate tool to produce the dump.
A dump can be analyzed using several approaches. For more information, see Analyzing a User-Mode Dump File.
A functioning app may fail immediately after upgrading either the .NET Core SDK on the development machine or changing package versions within the app. In some cases, incoherent packages may break an app when performing major upgrades. Most of these issues can be fixed by following these instructions:
Delete the bin and obj folders.
Clear the package caches by executing dotnet nuget locals all --clear from a command shell.
Clearing package caches can also be accomplished with the nuget.exe tool and executing the command nuget locals all -clear
. nuget.exe isn't a bundled install with the Windows desktop operating system and must be obtained separately from the NuGet website.
Restore and rebuild the project.
Delete all of the files in the deployment folder on the server prior to redeploying the app.
This article provides information on common app startup errors and instructions on how to diagnose errors when an app is deployed to Azure App Service or IIS:
App startup errors
Explains common startup HTTP status code scenarios.
Troubleshoot on Azure App Service
Provides troubleshooting advice for apps deployed to Azure App Service.
Troubleshoot on IIS
Provides troubleshooting advice for apps deployed to IIS or running on IIS Express locally. The guidance applies to both Windows Server and Windows desktop deployments.
Clear package caches
Explains what to do when incoherent packages break an app when performing major upgrades or changing package versions.
Additional resources
Lists additional troubleshooting topics.
In Visual Studio, the ASP.NET Core project default server is Kestrel. Visual studio can be configured to use IIS Express. A 502.5 - Process Failure or a 500.30 - Start Failure that occurs when debugging locally with IIS Express can be diagnosed using the advice in this topic.
The app fails to start. The following error is logged:
The Web server is configured to not list the contents of this directory.
The error is usually caused by a broken deployment on the hosting system, which includes any of the following scenarios:
Perform the following steps:
D:\home\site\wwwroot
folder.For more information on the layout of a published ASP.NET Core app, see ASP.NET Core directory structure. For more information on the web.config file, see ASP.NET Core Module (ANCM) for IIS.
The app starts, but an error prevents the server from fulfilling the request.
This error occurs within the app's code during startup or while creating a response. The response may contain no content, or the response may appear as a 500 Internal Server Error in the browser. The Application Event Log usually states that the app started normally. From the server's perspective, that's correct. The app did start, but it can't generate a valid response. Run the app at a command prompt on the server or enable the ASP.NET Core Module stdout log to troubleshoot the problem.
This error also may occur when the .NET Core Hosting Bundle isn't installed or is corrupted. Installing or repairing the installation of the .NET Core Hosting Bundle (for IIS) or Visual Studio (for IIS Express) may fix the problem.
The worker process fails. The app doesn't start.
An unknown error occurred loading ASP.NET Core Module components. Take one of the following actions:
The worker process fails. The app doesn't start.
The ASP.NET Core Module attempts to start the .NET Core CLR in-process, but it fails to start. The cause of a process startup failure can usually be determined from entries in the Application Event Log and the ASP.NET Core Module stdout log.
Common failure conditions:
The worker process fails. The app doesn't start.
The ASP.NET Core Module attempts to start the .NET Core runtime in-process, but it fails to start. The most common cause of this startup failure is when the Microsoft.NETCore.App
or Microsoft.AspNetCore.App
runtime isn't installed. If the app is deployed to target ASP.NET Core 3.0 and that version doesn't exist on the machine, this error occurs. An example error message follows:
The specified framework 'Microsoft.NETCore.App', version '3.0.0' was not found.
- The following frameworks were found:
2.2.1 at [C:\Program Files\dotnet\x64\shared\Microsoft.NETCore.App]
3.0.0-preview5-27626-15 at [C:\Program Files\dotnet\x64\shared\Microsoft.NETCore.App]
3.0.0-preview6-27713-13 at [C:\Program Files\dotnet\x64\shared\Microsoft.NETCore.App]
3.0.0-preview6-27714-15 at [C:\Program Files\dotnet\x64\shared\Microsoft.NETCore.App]
3.0.0-preview6-27723-08 at [C:\Program Files\dotnet\x64\shared\Microsoft.NETCore.App]
The error message lists all the installed .NET Core versions and the version requested by the app. To fix this error, either:
When running in development (the ASPNETCORE_ENVIRONMENT
environment variable is set to Development
), the specific error is written to the HTTP response. The cause of a process startup failure is also found in the Application Event Log.
The worker process fails. The app doesn't start.
The most common cause for this error is that the app is published for an incompatible processor architecture. If the worker process is running as a 32-bit app and the app was published to target 64-bit, this error occurs.
To fix this error, either:
The worker process fails. The app doesn't start.
The app didn't reference the Microsoft.AspNetCore.App
framework. Only apps targeting the Microsoft.AspNetCore.App
framework can be hosted by the ASP.NET Core Module.
To fix this error, confirm that the app is targeting the Microsoft.AspNetCore.App
framework. Check the .runtimeconfig.json
to verify the framework targeted by the app.
The worker process can't run both an in-process app and an out-of-process app in the same process.
To fix this error, run apps in separate IIS application pools.
The worker process can't run multiple in-process apps in the same process.
To fix this error, run apps in separate IIS application pools.
The out-of-process request handler, aspnetcorev2_outofprocess.dll, isn't next to the aspnetcorev2.dll file. This indicates a corrupted installation of the ASP.NET Core Module.
To fix this error, repair the installation of the .NET Core Hosting Bundle (for IIS) or Visual Studio (for IIS Express).
ANCM failed to start within the provided startup time limit. By default, the timeout is 120 seconds.
This error can occur when starting a large number of apps on the same machine. Check for CPU/Memory usage spikes on the server during startup. You may need to stagger the startup process of multiple apps.
ANCM failed to locate the application DLL, which should be next to the executable.
This error occurs when hosting an app packaged as a single-file executable using the in-process hosting model. The in-process model requires that the ANCM load the .NET Core app into the existing IIS process. This scenario isn't supported by the single-file deployment model. Use one of the following approaches in the app's project file to fix this error:
PublishSingleFile
MSBuild property to false
.AspNetCoreHostingModel
MSBuild property to OutOfProcess
.The worker process fails. The app doesn't start.
The ASP.NET Core Module attempts to start the worker process but it fails to start. The cause of a process startup failure can usually be determined from entries in the Application Event Log and the ASP.NET Core Module stdout log.
A common failure condition is the app is misconfigured due to targeting a version of the ASP.NET Core shared framework that isn't present. Check which versions of the ASP.NET Core shared framework are installed on the target machine. The shared framework is the set of assemblies (.dll files) that are installed on the machine and referenced by a metapackage such as Microsoft.AspNetCore.App
. The metapackage reference can specify a minimum required version. For more information, see The shared framework.
The 502.5 Process Failure error page is returned when a hosting or app misconfiguration causes the worker process to fail:
EventID: 1010
Source: IIS AspNetCore Module V2
Failed to start application '/LM/W3SVC/6/ROOT/', ErrorCode '0x800700c1'.
The app failed to start because the app's assembly (.dll) couldn't be loaded.
This error occurs when there's a bitness mismatch between the published app and the w3wp/iisexpress process.
Confirm that the app pool's 32-bit setting is correct:
True
.False
.Confirm that there isn't a conflict between a <Platform>
MSBuild property in the project file and the published bitness of the app.
EventID: 1010
Source: IIS AspNetCore Module V2
Failed to start application '/LM/W3SVC/3/ROOT', ErrorCode '0x800701b1'.
The app failed to start because a Windows Service failed to load.
One common service that needs to be enabled is the "null" service.
The following command enables the null
Windows Service:
sc.exe start null
If an error occurs after the headers are sent, it's too late for the server to send a 500 Internal Server Error when an error occurs. This often happens when an error occurs during the serialization of complex objects for a response. This type of error appears as a connection reset error on the client. Application logging can help troubleshoot these types of errors.
The ASP.NET Core Module is configured with a default startupTimeLimit of 120 seconds. When left at the default value, an app may take up to two minutes to start before the module logs a process failure. For information on configuring the module, see Attributes of the aspNetCore element.
Važno
ASP.NET Core preview releases with Azure App Service
ASP.NET Core preview releases aren't deployed to Azure App Service by default. To host an app that uses an ASP.NET Core preview release, see Deploy ASP.NET Core preview release to Azure App Service.
The Azure App Services Log streams logging information as it occurs. To view streaming logs:
The following images shows the application logs output:
Streaming logs have some latency and might not display immediately.
To access the Application Event Log, use the Diagnose and solve problems blade in the Azure portal:
An alternative to using the Diagnose and solve problems blade is to examine the Application Event Log file directly using Kudu:
eventlog.xml
file.Many startup errors don't produce useful information in the Application Event Log. You can run the app in the Kudu Remote Execution Console to discover the error:
Current release
cd d:\home\site\wwwroot
If the app is a framework-dependent deployment:
dotnet .\{ASSEMBLY NAME}.dll
If the app is a self-contained deployment:
{ASSEMBLY NAME}.exe
The console output from the app, showing any errors, is piped to the Kudu console.
Framework-dependent deployment running on a preview release
Requires installing the ASP.NET Core {VERSION} (x86) Runtime site extension.
cd D:\home\SiteExtensions\AspNetCoreRuntime.{X.Y}.x32
({X.Y}
is the runtime version)dotnet \home\site\wwwroot\{ASSEMBLY NAME}.dll
The console output from the app, showing any errors, is piped to the Kudu console.
Current release
cd D:\Program Files\dotnet
dotnet \home\site\wwwroot\{ASSEMBLY NAME}.dll
cd D:\home\site\wwwroot
{ASSEMBLY NAME}.exe
The console output from the app, showing any errors, is piped to the Kudu console.
Framework-dependent deployment running on a preview release
Requires installing the ASP.NET Core {VERSION} (x64) Runtime site extension.
cd D:\home\SiteExtensions\AspNetCoreRuntime.{X.Y}.x64
({X.Y}
is the runtime version)dotnet \home\site\wwwroot\{ASSEMBLY NAME}.dll
The console output from the app, showing any errors, is piped to the Kudu console.
Upozorenje
Failure to disable the stdout log can lead to app or server failure. There's no limit on log file size or the number of log files created. Only use stdout logging to troubleshoot app startup problems.
For general logging in an ASP.NET Core app after startup, use a logging library that limits log file size and rotates logs. For more information, see third-party logging providers.
The ASP.NET Core Module stdout log often records useful error messages not found in the Application Event Log. To enable and view stdout logs:
<aspNetCore />
element, set stdoutLogEnabled="true"
and select Save.Disable stdout logging when troubleshooting is complete by setting stdoutLogEnabled="false"
.
For more information, see ASP.NET Core Module (ANCM) for IIS.
The ASP.NET Core Module debug log provides additional, deeper logging from the ASP.NET Core Module. To enable and view stdout logs:
<handlerSettings>
shown in Enhanced diagnostic logs to the live app's web.config file using the Kudu console:
<handlerSettings>
section as shown in Enhanced diagnostic logs. Select the Save button.Disable debug logging when troubleshooting is complete:
To disable the enhanced debug log, perform either of the following:
<handlerSettings>
from the web.config file locally and redeploy the app.<handlerSettings>
section. Save the file.For more information, see Log creation and redirection with the ASP.NET Core Module.
Upozorenje
Failure to disable the debug log can lead to app or server failure. There's no limit on log file size. Only use debug logging to troubleshoot app startup problems.
For general logging in an ASP.NET Core app after startup, use a logging library that limits log file size and rotates logs. For more information, see third-party logging providers.
When an app responds slowly or doesn't respond to a request, see Troubleshoot slow web app performance issues in Azure App Service.
Monitoring blades provide an alternative troubleshooting experience to the methods described earlier in the topic. These blades can be used to diagnose 500-series errors.
Confirm that the ASP.NET Core Extensions are installed. If the extensions aren't installed, install them manually:
If stdout logging isn't enabled, follow these steps:
true
and change the stdoutLogFile path to: \\?\%home%\LogFiles\stdout
.Proceed to activate diagnostic logging:
Be sure to disable stdout logging when troubleshooting is complete.
To view the failed request tracing logs (FREB logs):
See Failed request traces section of the Enable diagnostics logging for web apps in Azure App Service topic and the Application performance FAQs for Web Apps in Azure: How do I turn on failed request tracing? for more information.
For more information, see Enable diagnostics logging for web apps in Azure App Service.
Upozorenje
Failure to disable the stdout log can lead to app or server failure. There's no limit on log file size or the number of log files created.
For routine logging in an ASP.NET Core app, use a logging library that limits log file size and rotates logs. For more information, see third-party logging providers.
Access the Application Event Log:
Many startup errors don't produce useful information in the Application Event Log. You can find the cause of some errors by running the app at a command prompt on the hosting system.
If the app is a framework-dependent deployment:
dotnet .\<assembly_name>.dll
.http://localhost:5000/
. If the app responds normally at the Kestrel endpoint address, the problem is more likely related to the hosting configuration and less likely within the app.If the app is a self-contained deployment:
<assembly_name>.exe
.http://localhost:5000/
. If the app responds normally at the Kestrel endpoint address, the problem is more likely related to the hosting configuration and less likely within the app.To enable and view stdout logs:
true
and change the stdoutLogFile path to point to the logs folder (for example, .\logs\stdout
). stdout
in the path is the log file name prefix. A timestamp, process id, and file extension are added automatically when the log is created. Using stdout
as the file name prefix, a typical log file is named stdout_20180205184032_5412.log.Disable stdout logging when troubleshooting is complete:
false
.For more information, see ASP.NET Core Module (ANCM) for IIS.
Upozorenje
Failure to disable the stdout log can lead to app or server failure. There's no limit on log file size or the number of log files created.
For routine logging in an ASP.NET Core app, use a logging library that limits log file size and rotates logs. For more information, see third-party logging providers.
Add the following handler settings to the app's web.config file to enable ASP.NET Core Module debug log:
<aspNetCore ...>
<handlerSettings>
<handlerSetting name="debugLevel" value="file" />
<handlerSetting name="debugFile" value="c:\temp\ancm.log" />
</handlerSettings>
</aspNetCore>
Confirm that the path specified for the log exists and that the app pool's identity has write permissions to the location.
For more information, see Log creation and redirection with the ASP.NET Core Module.
The ASPNETCORE_ENVIRONMENT
environment variable can be added to web.config to run the app in the Development environment. As long as the environment isn't overridden in app startup by UseEnvironment
on the host builder, setting the environment variable allows the Developer Exception Page to appear when the app is run.
<aspNetCore processPath="dotnet"
arguments=".\MyApp.dll"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout"
hostingModel="InProcess">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
Setting the environment variable for ASPNETCORE_ENVIRONMENT
is only recommended for use on staging and testing servers that aren't exposed to the Internet. Remove the environment variable from the web.config file after troubleshooting. For information on setting environment variables in web.config, see environmentVariables child element of aspNetCore.
If an app is capable of responding to requests, obtain request, connection, and additional data from the app using terminal inline middleware. For more information and sample code, see Troubleshoot and debug ASP.NET Core projects.
A crash dump is a snapshot of the system's memory and can help determine the cause of an app crash, startup failure, or slow app.
Obtain and analyze a dump from Windows Error Reporting (WER):
Create a folder to hold crash dump files at c:\dumps
. The app pool must have write access to the folder.
Run the EnableDumps PowerShell script:
If the app uses the in-process hosting model, run the script for w3wp.exe:
.\EnableDumps w3wp.exe c:\dumps
If the app uses the out-of-process hosting model, run the script for dotnet.exe:
.\EnableDumps dotnet.exe c:\dumps
Run the app under the conditions that cause the crash to occur.
After the crash has occurred, run the DisableDumps PowerShell script:
If the app uses the in-process hosting model, run the script for w3wp.exe:
.\DisableDumps w3wp.exe
If the app uses the out-of-process hosting model, run the script for dotnet.exe:
.\DisableDumps dotnet.exe
After an app crashes and dump collection is complete, the app is allowed to terminate normally. The PowerShell script configures WER to collect up to five dumps per app.
Upozorenje
Crash dumps might take up a large amount of disk space (up to several gigabytes each).
When an app stops responding but doesn't crash, fails during startup, or runs normally, see User-Mode Dump Files: Choosing the Best Tool to select an appropriate tool to produce the dump.
A dump can be analyzed using several approaches. For more information, see Analyzing a User-Mode Dump File.
A functioning app may fail immediately after upgrading either the .NET Core SDK on the development machine or changing package versions within the app. In some cases, incoherent packages may break an app when performing major upgrades. Most of these issues can be fixed by following these instructions:
Delete the bin and obj folders.
Clear the package caches by executing dotnet nuget locals all --clear from a command shell.
Clearing package caches can also be accomplished with the nuget.exe tool and executing the command nuget locals all -clear
. nuget.exe isn't a bundled install with the Windows desktop operating system and must be obtained separately from the NuGet website.
Restore and rebuild the project.
Delete all of the files in the deployment folder on the server prior to redeploying the app.
Povratne informacije za ASP.NET Core
ASP.NET Core je projekat otvorenog koda. Izaberite vezu da biste pružili povratne informacije:
Događaj
Power BI DataViz Svetsko prvenstvo
14. feb 16 - 31. mar 16
Sa 4 šanse za ulazak, možete osvojiti konferencijski paket i stići do LIVE Grand Finale u Las Vegasu
Saznajte višeObuka
Modul
Remotely debug ASP.NET Core apps hosted on Azure App Service using Visual Studio - Training
Hands-on training to deploy and remotely debug your ASP.NET Core apps on Azure App Service directly using Visual Studio 2022.