WebListener : A Windows HTTP server for ASP.NET Core

Special thanks to Mr.Tom Dykstra from Microsoft for suggesting some points for this post.

Web Listener is now available on Nuget.

First of all, what is Web Listener?

Web Listener is one of the servers of .Net core.

ASP.NET Core is completely decoupled from the web server environment that hosts the application. ASP.NET Core supports hosting in IIS and IIS Express, and self-hosting scenarios using the Kestrel and WebListener HTTP servers.

As per the .Net team says

WebListener is a Windows HTTP server built on the Http.Sys kernel mode driver. It exposes a number of Http.Sys features previously only availabe in IIS.

Fine, but when should we use Web Listener?

If you are on Windows and  if you want to expose your server directly to the internet. Because Kestrel is not certified for direct exposure.

Or you need any of the features listed below:

  • Windows Authentication
  • Port sharing
  • HTTPS with SNI
  • HTTP/2 over TLS (Windows 10)
  • Direct file transmission
  • Response caching

It is also Recommended for edge deployment because it’s built on the existing Http.Sys HTTP stack. Http.Sys is mature technology that protects against many kinds of attacks. Kestrel is newer, hasn’t had a chance to develop as many protective features yet.

NOTE: Please note that it is Not compatible with ASP.NET Core Module, so can’t be used with IIS even if you wanted to.

Example scenario:

  • Can use Kestrel for internal micro service to micro service communications on private network (kestrel faster), should use WebListener for directly externally facing micro service layer.
  • If a cluster is not on a closed private virtual network, should use WebListener for the inter-service communication as they are open to other things contacting them on their “internal” ports.

Great, and what are Supported Windows versions?

  • Windows 7 and Windows Server 2008 R2 and later

So, How to get it via Nuget?

You can get it using below command:

webl

Great, What to do after getting it from Nuget?

You can use it in code as shown below:

public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                .UseWebListener(options =>
                {
                    options.ListenerSettings.Authentication.Schemes = AuthenticationSchemes.NTLM;
                    options.ListenerSettings.Authentication.AllowAnonymous = false;
                })
                .UseStartup()
                .Build();

            host.Run();
        }

Awesome, anything extra needed to use WebListener?

Yes, below are few points I got from Mr.Tom Dykstra:

 

Happy coding!

Advertisement

2 thoughts on “WebListener : A Windows HTTP server for ASP.NET Core

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s