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 What is Rust? Safe, fast, and easy software development Unlike most programming languages, Rust doesn't make you choose between speed, safety, and ease of use. Find out how Rust delivers better code with fewer compromises, and a few downsides to consider before learning Rust. By Serdar Yegulalp Nov 20, 2024 11 mins Rust Programming Languages Software Development how-to Kotlin for Java developers: Classes and coroutines Kotlin was designed to bring more flexibility and flow to programming in the JVM. Here's an in-depth look at how Kotlin makes working with classes and objects easier and introduces coroutines to modernize concurrency. By Matthew Tyson Nov 20, 2024 9 mins Java Kotlin Programming Languages analysis Azure AI Foundry tools for changes in AI applications Microsoft’s launch of Azure AI Foundry at Ignite 2024 signals a welcome shift from chatbots to agents and to using AI for business process automation. By Simon Bisson Nov 20, 2024 7 mins Microsoft Azure Generative AI Development Tools news Microsoft unveils imaging APIs for Windows Copilot Runtime Generative AI-backed APIs will allow developers to build image super resolution, image segmentation, object erase, and OCR capabilities into Windows applications. By Paul Krill Nov 19, 2024 2 mins Generative AI APIs Development Libraries and Frameworks Resources Videos