"
ASP.NET (snapshot 2017) Microsoft documentation and samples

WebListener web server implementation in ASP.NET Core

By Tom Dykstra and Chris Ross

[!NOTE] This topic applies only to ASP.NET Core 1.x. In ASP.NET Core 2.0, WebListener is named HTTP.sys.

WebListener is a web server for ASP.NET Core that runs only on Windows. It’s built on the Http.Sys kernel mode driver. WebListener is an alternative to Kestrel that can be used for direct connection to the Internet without relying on IIS as a reverse proxy server. In fact, WebListener can’t be used with IIS or IIS Express, as it isn’t compatible with the ASP.NET Core Module.

Although WebListener was developed for ASP.NET Core, it can be used directly in any .NET Core or .NET Framework application via the Microsoft.Net.Http.Server NuGet package.

WebListener supports the following features:

Supported Windows versions:

View or download sample code ((xref:)how to download)

When to use WebListener

WebListener is useful for deployments where you need to expose the server directly to the Internet without using IIS.

Weblistener communicates directly with the Internet
Weblistener communicates directly with the Internet

Because it’s built on Http.Sys, WebListener doesn’t require a reverse proxy server for protection against attacks. Http.Sys is mature technology that protects against many kinds of attacks and provides the robustness, security, and scalability of a full-featured web server. IIS itself runs as an HTTP listener on top of Http.Sys.

WebListener is also a good choice for internal deployments when you need one of the features it offers that you can’t get by using Kestrel.

Weblistener communicates directly with your internal network
Weblistener communicates directly with your internal network

How to use WebListener

Here’s an overview of setup tasks for the host OS and your ASP.NET Core application.

Configure Windows Server

There are also Http.Sys registry settings.

Configure your ASP.NET Core application

How to use WebListener outside of ASP.NET Core

There are also Http.Sys registry settings.

Here’s a code sample that demonstrates WebListener use outside of ASP.NET Core:

Preregister URL prefixes and configure SSL

Both IIS and WebListener rely on the underlying Http.Sys kernel mode driver to listen for requests and do initial processing. In IIS, the management UI gives you a relatively easy way to configure everything. However, if you’re using WebListener you need to configure Http.Sys yourself. The built-in tool for doing that is netsh.exe.

The most common tasks you need to use netsh.exe for are reserving URL prefixes and assigning SSL certificates.

NetSh.exe is not an easy tool to use for beginners. The following example shows the bare minimum needed to reserve URL prefixes for ports 80 and 443:

netsh http add urlacl url=http://+:80/ user=Users
netsh http add urlacl url=https://+:443/ user=Users

The following example shows how to assign an SSL certificate:

netsh http add sslcert ipport=0.0.0.0:443 certhash=MyCertHash_Here appid={00000000-0000-0000-0000-000000000000}".

Here is the official reference documentation:

The following resources provide detailed instructions for several scenarios. Articles that refer to HttpListener apply equally to WebListener, as both are based on Http.Sys.

Here are some third-party tools that can be easier to use than the netsh.exe command line. These are not provided by or endorsed by Microsoft. The tools run as administrator by default, since netsh.exe itself requires administrator privileges.

For generating self-signed SSL certificates, Microsoft provides command-line tools: MakeCert.exe and the PowerShell cmdlet New-SelfSignedCertificate. There are also third-party UI tools that make it easier for you to generate self-signed SSL certificates:

Next steps

For more information, see the following resources:



Comments ( )
Link to this page: //www.vb-net.com/AspNet-DocAndSamples-2017/aspnetcore/fundamentals/servers/weblistener.htm
< THANKS ME>