Learn how to implement HTTP.sys, a Windows-only HTTP server based on the HTTP.sys kernel driver that is mature, secure and scalable in ASP.Net Core Credit: Thinkstock ASP.Net Core is an open source, cross-platform, lean, and modular framework for building high-performance web applications. Kestrel is a cross-platform web server for ASP.Net Core that is include by default. However, it has limitations. To get around those limitations, I suggest you use HTTP.sys, a Windows-only HTTP server based on the HTTP.sys kernel driver that is more mature, secure, and scalable. Why you should use HTTP.sys Typically, you need HTTP.sys when you have to expose your server to the outside world sans IIS (Microsoft Internet Information Services). The requests first come to the HTTP.sys—built on the HTTP.sys Kernel mode driver. HTTP.sys in turn creates a queue as well as an individual application pool for each request based on the request. You can also use HTTP.sys when you need a feature that is not supported by Kestrel. Features supported by HTTP.sys include: Windows Authentication Web Sockets Post Sharing HTTPS Response caching Direct file transmission Get a project started in HTTP.sys If you’re running Visual Studio 2017, follow these steps to create an ASP.Net Core Web API project: In the Visual Studio IDE, choose File > New > Project. Select ASP.Net Core Web Application (.Net Core) from the list of the templates displayed. Specify UsingHTTPSysInCode as the name for the project. Click OK to save the project. Select API in the New .Net Core Web Application window. Select the version of ASP.Net Core you want to use from the drop-down menu at the top. Uncheck Enable Docker Support and select No Authentication, because you won’t be using either of these here. Click OK. These steps create a new ASP.Net Core Project named UsingHTTPSysInCode in Visual Studio 2017. Configure the ASP.net Core application for HTTP.sys Next, you should install the packages you need. The best way to do this is to install the Microsoft.AspNetCore.All meta package via the NuGet package manager. This ensures that all necessary packages are installed at one go. Then open the Program.cs file in your project. It should look like this: public class Program { public static void Main(string[] args) { CreateWebHostBuilder(args).Build().Run(); } public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>(); } With the packages installed, configure HTTP.sys server via the UseHttpSys extension method of WebHostBuilder in the Main method for the Program class in Program.cs file. Here’s how: public static void Main(string[] args) { CreateWebHostBuilder(args).Run(); } public static IWebHost CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .UseHttpSys(options => { options.Authentication.Schemes = AuthenticationSchemes.None; options.Authentication.AllowAnonymous = true; options.MaxConnections = 100; options.MaxRequestBodySize = 1000000; options.UrlPrefixes.Add("http://localhost:5000"); }) .Build(); Here’s the complete source code of the Program class: using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Server.HttpSys; namespace UsingHTTPSysInCode { public class Program { public static void Main(string[] args) { CreateWebHostBuilder(args).Run(); } public static IWebHost CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .UseHttpSys(options => { options.Authentication.Schemes = AuthenticationSchemes.None; options.Authentication.AllowAnonymous = true; options.MaxConnections = 100; options.MaxRequestBodySize = 1000000; options.UrlPrefixes.Add("http://localhost:5000"); }) .Build(); } } Finally, when you run the application, ensure that you select the launch profile appropriately. The default launch profile is IIS in Visual Studio. Select UsingHTTPSysInCode for this example; it is the same as the name of the project as well as the namespace. When you run the application with the launch profile as UsingHTTPSysInCode, a console window opens to display the series of steps being executed before you see the output of the Get method of the ValuesController (assuming that’s your default controller) in your web browser. Related content how-to How to use FastEndpoints in ASP.NET Core Take advantage of the free open-source FastEndpoints library to build fast and lean APIs in your ASP.NET Core applications. By Joydip Kanjilal Jul 11, 2024 7 mins Microsoft .NET C# Development Libraries and Frameworks how-to How to use Refit to consume APIs in ASP.NET Core Take advantage of Refit REST library to simplify API consumption and make your code cleaner, more efficient, and easier to maintain. By Joydip Kanjilal Jul 04, 2024 10 mins C# Microsoft .NET Software Deployment how-to When to use an abstract class vs. interface in C# Understanding the differences between an abstract class and interface is key to designing loosely coupled and extensible applications. By Joydip Kanjilal Jun 20, 2024 10 mins Small and Medium Business Microsoft .NET C# how-to 6 security best practices for ASP.NET Core Learn the best practices and built-in safeguards for preventing attacks and protecting sensitive data in your ASP.NET Core web applications. By Joydip Kanjilal Jun 07, 2024 6 mins C# Microsoft .NET Web Development Resources Videos