--- title: ASP.NET Core Module configuration reference author: guardrex description: How to configure the ASP.NET Core Module for hosting ASP.NET Core applications. keywords: ASP.NET Core,ancm,core module,iis,stdout logging,environment variable,env var,subapplication,subapp,appoffline,app_offline,502,schema ms.author: riande manager: wpickett ms.date: 03/07/2017 ms.topic: article ms.assetid: 5de0c8f7-50ce-4e2c-b3d4-a1bd9fdfcff5 ms.technology: aspnet ms.prod: asp.net-core uid: hosting/aspnet-core-module --- # ASP.NET Core Module configuration reference By [Luke Latham](https://github.com/guardrex), [Rick Anderson](https://twitter.com/RickAndMSFT), and [Sourabh Shirhatti](https://twitter.com/sshirhatti) This document provides details on how to configure the ASP.NET Core Module for hosting ASP.NET Core applications. For an introduction to the ASP.NET Core Module and installation instructions, see the [ASP.NET Core Module overview](xref:fundamentals/servers/aspnet-core-module). ## Configuration via web.config The ASP.NET Core Module is configured via a site or application *web.config* file and has its own `aspNetCore` configuration section within `system.webServer`. Here's an example *web.config* file that the `Microsoft.NET.Sdk.Web` SDK will provide when the project is published for a [framework-dependent deployment](https://docs.microsoft.com/dotnet/articles/core/deploying/#framework-dependent-deployments-fdd) with placeholders for the `processPath` and `arguments`: ```xml ``` The *web.config* example below is for a [self-contained deployment](https://docs.microsoft.com/dotnet/articles/core/deploying/#self-contained-deployments-scd) to the [Azure App Service](https://azure.microsoft.com/services/app-service/). For more information, see [Publishing to IIS](xref:publishing/iis). See [Configuration of sub-applications](xref:publishing/iis#configuration-of-sub-applications) for an important note pertaining to the configuration of *web.config* files in sub-applications. ```xml ``` ### Attributes of the aspNetCore element | Attribute | Description | | --- | --- | | processPath |

Required string attribute.

Path to the executable that will launch a process listening for HTTP requests. Relative paths are supported. If the path begins with '.', the path is considered to be relative to the site root.

There is no default value.

| | arguments |

Optional string attribute.

Arguments to the executable specified in **processPath**.

The default value is an empty string.

| | startupTimeLimit |

Optional integer attribute.

Duration in seconds that the module will wait for the executable to start a process listening on the port. If this time limit is exceeded, the module will kill the process. The module will attempt to launch the process again when it receives a new request and will continue to attempt to restart the process on subsequent incoming requests unless the application fails to start **rapidFailsPerMinute** number of times in the last rolling minute.

The default value is 120.

| | shutdownTimeLimit |

Optional integer attribute.

Duration in seconds for which the module will wait for the executable to gracefully shutdown when the *app_offline.htm* file is detected.

The default value is 10.

| | rapidFailsPerMinute |

Optional integer attribute.

Specifies the number of times the process specified in **processPath** is allowed to crash per minute. If this limit is exceeded, the module will stop launching the process for the remainder of the minute.

The default value is 10.

| | requestTimeout |

Optional timespan attribute.

Specifies the duration for which the ASP.NET Core Module will wait for a response from the process listening on %ASPNETCORE_PORT%.

The default value is "00:02:00".

| | stdoutLogEnabled |

Optional Boolean attribute.

If true, **stdout** and **stderr** for the process specified in **processPath** will be redirected to the file specified in **stdoutLogFile**.

The default value is false.

| | stdoutLogFile |

Optional string attribute.

Specifies the relative or absolute file path for which **stdout** and **stderr** from the process specified in **processPath** will be logged. Relative paths are relative to the root of the site. Any path starting with '.' will be relative to the site root and all other paths will be treated as absolute paths. Any folders provided in the path must exist in order for the module to create the log file. The process ID, timestamp (*yyyyMdhms*), and file extension (*.log*) with underscore delimiters are added to the last segment of the **stdoutLogFile** provided.

The default value is `aspnetcore-stdout`.

| | forwardWindowsAuthToken | true or false.

If true, the token will be forwarded to the child process listening on %ASPNETCORE_PORT% as a header 'MS-ASPNETCORE-WINAUTHTOKEN' per request. It is the responsibility of that process to call CloseHandle on this token per request.

The default value is true.

| | disableStartUpErrorPage | true or false.

If true, the **502.5 - Process Failure** page will be suppressed, and the 502 status code page configured in your *web.config* will take precedence.

The default value is false.

| ### Setting environment variables The ASP.NET Core Module allows you specify environment variables for the process specified in the `processPath` attribute by specifying them in one or more `environmentVariable` child elements of an `environmentVariables` collection element under the `aspNetCore` element. Environment variables set in this section take precedence over system environment variables for the process. The example below sets two environment variables. `ASPNETCORE_ENVIRONMENT` will configure the application's environment to `Development`. A developer may temporarily set this value in the *web.config* file in order to force the [developer exception page](xref:fundamentals/error-handling) to load when debugging an app exception. `CONFIG_DIR` is an example of a user-defined environment variable, where the developer has written code that will read the value on startup to form a path in order to load the app's configuration file. ```xml ``` ## app_offline.htm If you place a file with the name *app_offline.htm* at the root of a web application directory, the ASP.NET Core Module will attempt to gracefully shutdown the app and stop processing incoming requests. If the app is still running after `shutdownTimeLimit` number of seconds, the ASP.NET Core Module will kill the running process. While the *app_offline.htm* file is present, the ASP.NET Core Module will respond to requests by sending back the contents of the *app_offline.htm* file. Once the *app_offline.htm* file is removed, the next request loads the application, which then responds to requests. ## Start-up error page If the ASP.NET Core Module fails to launch the backend process or the backend process starts but fails to listen on the configured port, you will see an HTTP 502.5 status code page. To suppress this page and revert to the default IIS 502 status code page, use the `disableStartUpErrorPage` attribute. For more information on configuring custom error messages, see [HTTP Errors ``](https://docs.microsoft.com/iis/configuration/system.webServer/httpErrors/). ![502 Status Page](aspnet-core-module/_static/ANCM-502_5.png) ## Log creation and redirection The ASP.NET Core Module redirects `stdout` and `stderr` logs to disk if you set the `stdoutLogEnabled` and `stdoutLogFile` attributes of the `aspNetCore` element. Any folders in the `stdoutLogFile` path must exist in order for the module to create the log file. A timestamp and file extension will be added automatically when the log file is created. Logs are not rotated, unless process recycling/restart occurs. It is the responsibility of the hoster to limit the disk space the logs consume. Using the `stdout` log is only recommended for troubleshooting application startup issues and not for general application logging purposes. The log file name is composed by appending the process ID (PID), timestamp (*yyyyMdhms*), and file extension (*.log*) to the last segment of the `stdoutLogFile` path (typically *stdout*) delimited by underscores. For example if the `stdoutLogFile` path ends with *stdout*, a log for an app with a PID of 10652 created on 8/10/2017 at 12:05:02 has the file name *stdout_10652_20178101252.log*. Here's a sample `aspNetCore` element that configures `stdout` logging. The `stdoutLogFile` path shown in the example is appropriate for the Azure App Service. A local path or network share path is acceptable for local logging. Confirm that the AppPool user identity has permission to write to the path provided. ```xml ``` ## ASP.NET Core Module with an IIS Shared Configuration The ASP.NET Core Module installer runs with the privileges of the **SYSTEM** account. Because the local system account does not have modify permission for the share path which is used by the IIS Shared Configuration, the installer will hit an access denied error when attempting to configure the module settings in *applicationHost.config* on the share. The unsupported workaround is to disable the IIS Shared Configuration, run the installer, export the updated *applicationHost.config* file to the share, and re-enable the IIS Shared Configuration. ## Module, schema, and configuration file locations ### Module **IIS (x86/amd64):** * %windir%\System32\inetsrv\aspnetcore.dll * %windir%\SysWOW64\inetsrv\aspnetcore.dll **IIS Express (x86/amd64):** * %ProgramFiles%\IIS Express\aspnetcore.dll * %ProgramFiles(x86)%\IIS Express\aspnetcore.dll ### Schema **IIS** * %windir%\System32\inetsrv\config\schema\aspnetcore_schema.xml **IIS Express** * %ProgramFiles%\IIS Express\config\schema\aspnetcore_schema.xml ### Configuration **IIS** * %windir%\System32\inetsrv\config\applicationHost.config **IIS Express** * .vs\config\applicationHost.config You can search for *aspnetcore.dll* in the *applicationHost.config* file. For IIS Express, the *applicationHost.config* file won't exist by default. The file is created at *{application root}\.vs\config* when you start any web application project in the Visual Studio solution.