Welcome to my blog!

Publishing and Running ASP.NET Core Applications with IIS

November 6, 2019 16:47

Publishing and Running ASP.NET Core Applications with IIS



Hosting ASP.NET on IIS

ASP.NET Core Applications with IIS

ASP.NET Core IIS Hosting

As of ASP.NET Core 2.2 IIS Hosting does support a new InProcess hosting mechanism. A seperate post describes the details of In Process/Out of Process hosting.

The AspNetCoreModule has to be installed on your server and is part of the ASP.NET Core Server Hosting Bundle.

The ASPNetCoreModule interfaces ASP.NET Core Console Applications

Here's what the web.config looks like:

<?xml version="1.0" encoding="utf-8"?>
    Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
      <add name="aspNetCore" path="*" verb="*"
        modules="AspNetCoreModule" resourceType="Unspecified" />
    <aspNetCore processPath="dotnet"
                forwardWindowsAuthToken="false" />

You can see that module references dotnetexe and the compiled entry point DLL that holds your Main method in your .NET Core application.

You can also provide an optional section for Environment Variables if you were explicitly configuring various configuration startup environment settings.

<aspNetCore processPath="dotnet"
        <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" />

Note that you should use these settings sparingly and rather rely on the configuration settings object which gives you more control. Limit environment variable settings for specific startup options you need to configure the global environment. Otherwise stick to configuration file settings - or on Azure use the application settings to merge values into your config.

IIS Identity and Permissions

You might also have to tweak the IIS App Pool Identity to something other than the default ApplicationPoolIdentity in order to ensure that your application has access to resources it needs to run. I generally start with NETWORKSERVICE and then move to a custom account that matches the actual rights required by the application.


Recent posts