Introduction

HTTP.sys is a Windows-based web server for ASP.NET Core. It is an alternative to Kestrel Server and it has some features that are not supported by Kestrel. It is built on HTTP.sys Kernel mode driver. It cannot be used with IIS Express or IIS due to it is incompatibility with the ASP.NET Core modules.

Following are the features supported by HTTP.sys.

It is very useful for deployments where we need to expose the server directly to the internet without IIS. It is built on HTTP.sys so it does not require a reverse proxy server for protection against attacks. HTTP.sys provides robustness, security and scalability of web server and it is mature technology which protects against many kinds of attacks. This web server is a good choice for internal deployments when the Windows authentication kind of feature is used that is not available with the Kestrel Server.

Configure Windows Server

Following are the items required to configure this Windows server.

Configure ASP.net Core application

Following are the steps to configure the ASP.NET application for HTTP.sys.

Program. cs

public class Program  
{  
    public static void Main(string[] args)  
    {  
        BuildWebHost(args).Run();  
    }  
    public static IWebHost BuildWebHost(string[] args) =>  
        WebHost.CreateDefaultBuilder(args)  
            .UseStartup<Startup>()  
            .UseHttpSys(options =>  
            {  
                options.Authentication.Schemes = AuthenticationSchemes.None;  
                options.Authentication.AllowAnonymous = true;  
                options.MaxConnections = 100;  
                options.MaxRequestBodySize = 30000000;  
                options.UrlPrefixes.Add("http://localhost:5000");  
            })  
            .Build();  
}

HTTP.sys options

Configure URLs and ports to listen on

ASP.net core application binds to "http://localhost:5000" by default. We can configure URL prefixes and Port by using one of the following methods.

The main advantage of UrlPrefixes is that we get an error message immediately if we try to add a prefix in the wrong format. The main advantage of the "UseUrls" method is that we can more easily switch between HTTP.sys and Kestrel.

Authentication

It exposes the HTTP.sys authentication configurations. It contains two properties.

It can be modified at any time before disposing of the listener.

Both HTTP.sys and IIS rely on the HTTP.sys kernel-mode driver to listen for and process requests. IIS provides an easy way to configure the application whereas HTTP.sys servers everything we need to configure by ourselves. The netsh.exe tool can help us to configure HTTP.sys. We can assign SSL certificates and reserve URL prefixes by using this tool. To run this tool, required administrative privileges.

Some third-party tools can be used to configure the HTTP.sys server. These tools are not provided by Microsoft and these tools run as administrators by default

The default launch profile is IIS Express in Visual Studio. To run the application as a console application, we need to manually change the selected profile or alternatively run the project using CLI.

CLI

Summary

Http. sys web server introduced with .net core framework 2.0. It is an alternative of the Kestrel server. It runs only with Windows. It cannot be used with IIS (or IIS Express) as it is incompatible with the ASP.NET Core Module.