ASP.NET Core Interview Question #215

What is web.config used for when hosting ASP.NET Core behind IIS?

Testing, Deployment & Hosting Senior Advanced

Quick Interview Answer

For an ASP.NET Core application hosted with IIS, web.config configures the ASP.NET Core Module and relevant IIS behavior. It can specify how the application process is started, hosting model, arguments, and diagnostic stdout logging settings.

Detailed Explanation

For an ASP.NET Core application hosted with IIS, web.config configures the ASP.NET Core Module and relevant IIS behavior. It can specify how the application process is started, hosting model, arguments, and diagnostic stdout logging settings.

It is not the main ASP.NET Core application configuration file; settings such as connection strings and application options are normally handled through the ASP.NET Core configuration system.

Production stdout logging should not be left enabled unnecessarily because log files can consume disk space and may contain diagnostic information.

Code Example

<system.webServer>
  <handlers>
    <add name="aspNetCore"
         path="*"
         verb="*"
         modules="AspNetCoreModuleV2"
         resourceType="Unspecified" />
  </handlers>
  <aspNetCore processPath="dotnet"
              arguments=".\MyApp.dll"
              stdoutLogEnabled="false"
              hostingModel="inprocess" />
</system.webServer>