asp.netiisasp.net-corekestrel-http-server

What is Kestrel (vs IIS / Express)?


What is the Kestrel web server and how does it relate to IIS / IIS Express?

I come from developing applications on IIS Express and hosting them on an IIS web server. With ASP.NET Core, I have a dependency on Microsoft.AspNetCore.Server.Kestrel and my startup has .UseServer("Microsoft.AspNetCore.Server.Kestrel"). But when I run my website, I still get the IIS Express icon in the system tray. Someone asked me if I was using IIS Express or Kestrel and I didn't know what to say!

I don't have any cross-platform requirements as I develop on a PC and host in Azure, so I'm confused if I even need Kestrel, but it doesn't seem like there's an alternative—even the simplest samples use Kestrel.


Solution

  • What is Kestrel?

    It's a full-blown web server. You can run your ASP.NET Core application using just Kestrel.

    But when I run my website, I still get the IIS Express icon in the system tray

    In your ASP.NET application, probably in the wwwroot directory, you'll see a web.config that contains this:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <system.webServer>
        <handlers>
        <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
        </handlers>
        <httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" startupTimeLimit="3600"/>
    </system.webServer>
    </configuration>
    

    This is the HttpPlatformHandler. Essentially, it forwards all requests to Kestrel. IIS Express (and IIS for that matter) will not run ASP.NET themselves anymore. Instead, they will act as proxies that simply pass requests and responses back and forth from Kestrel. There are still advantages of using IIS; specifically, it gives you security configuration, kernel-level caching, etc.