What does the AspNetCoreModule module for IIS implement?

Viewed 741

When hosting an ASP.NET Core website in IIS, we need to install the ASP.NET Core hosting bundle regardless of compiling the site as a self-contained assembly (which includes the framework and runtime libs).

This requirement does not change when running it out-of-process (where IIS forwards all requests to Kestrel).

What does the AspNetCoreModuleV2 module implement? Are there any alternatives (apart from not running inside IIS)?

1 Answers

As explained by the documentation:

The ASP.NET Core Module is a native IIS module that plugs into the IIS pipeline, allowing ASP.NET Core applications to work with IIS. Run ASP.NET Core apps with IIS by either:

So depending on your hosting model, the module will operate slightly different but in the end it will still do the same: It will allow IIS to directly host your ASP.NET Core application. The reason why this is necessary is because IIS itself has a peculiar way of hosting websites and processing requests that is very specific to how classic ASP.NET works.

But since ASP.NET Core neither uses the .NET Framework runtime, nor utilize the classic ASP.NET application model, there needs to be “something“ that stops IIS from applying the default ASP.NET pipeline to ASP.NET Core applications. And that’s the job of the ASP.NET Core IIS Module.

Installing the module basically adds the functionality for the two hosting models to IIS, which can then be activated through the web.config—which ASP.NET Core will generate for you.

If you want to host your ASP.NET Core application through IIS, then there is effectively no way around installing some module. The ASP.NET Core module is the best way to correctly integrate the app into IIS. If you do not want to use the ASP.NET Core module, then you can also host the app directly on Kestrel, e.g. as a Windows service, and then configure IIS to be a full reverse proxy to your ASP.NET Core application. However, in order to do that, you will need to use the Application Request Routing module (and its dependency URL Rewrite) because IIS does not come with reverse proxy functionality out of the box.

A final note on the ASP.NET Core module: The module really only includes the bits that are required for IIS to host the application. It has no impact on the application code, and you will still need to have the .NET Core runtime either installed separately, or deploy your application as a self-contained application. You will however not need to regularly update the hosting module since there are very little changes. So usually, it is something you install once and then stop thinking about.


‡ The .NET Core runtime is included in the hosting module by default but you can also install just the hosting module on its own, which is just under 2 MiB.

Related