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 feature 14 great preprocessors for developers who love to code Sometimes it seems like the rules of programming are designed to make coding a chore. Here are 14 ways preprocessors can help make software development fun again. By Peter Wayner Nov 18, 2024 10 mins Development Tools Software Development feature Designing the APIs that accidentally power businesses Well-designed APIs, even those often-neglected internal APIs, make developers more productive and businesses more agile. By Jean Yang Nov 18, 2024 6 mins APIs Software Development news Spin 3.0 supports polyglot development using Wasm components Fermyon’s open source framework for building server-side WebAssembly apps allows developers to compose apps from components created with different languages. By Paul Krill Nov 18, 2024 2 mins Microservices Serverless Computing Development Libraries and Frameworks news Go language evolving for future hardware, AI workloads The Go team is working to adapt Go to large multicore systems, the latest hardware instructions, and the needs of developers of large-scale AI systems. By Paul Krill Nov 15, 2024 3 mins Google Go Generative AI Programming Languages Resources Videos