AspNetCoreSharedServer.Middleware 4.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package AspNetCoreSharedServer.Middleware --version 4.2.0
                    
NuGet\Install-Package AspNetCoreSharedServer.Middleware -Version 4.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AspNetCoreSharedServer.Middleware" Version="4.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AspNetCoreSharedServer.Middleware" Version="4.2.0" />
                    
Directory.Packages.props
<PackageReference Include="AspNetCoreSharedServer.Middleware" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AspNetCoreSharedServer.Middleware --version 4.2.0
                    
#r "nuget: AspNetCoreSharedServer.Middleware, 4.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AspNetCoreSharedServer.Middleware@4.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AspNetCoreSharedServer.Middleware&version=4.2.0
                    
Install as a Cake Addin
#tool nuget:?package=AspNetCoreSharedServer.Middleware&version=4.2.0
                    
Install as a Cake Tool

AspNetCoreSharedServer.Middleware

Middleware for ASP.NET Core applications that run behind AspNetCoreSharedServer.

UseAspNetCoreSharedServer

One method name, two places to call it: on the application (app) for HTTP/3, and on the web host (builder.WebHost) for the PROXY protocol. Both do nothing outside AspNetCoreSharedServer.

HTTP/3 (app.UseAspNetCoreSharedServer())

AspNetCoreSharedServer can forward HTTP/3 (QUIC over UDP) to your application. Clients learn that HTTP/3 is available from the Alt-Svc header of a normal HTTP/1.1 or HTTP/2 response. Kestrel only knows its own internal port, so on its own it would advertise a port that clients cannot reach. AspNetCoreSharedServer therefore passes the correct header value, for example h3=":443"; ma=86400, to the application in the environment variable HTTP3_ALT_SVC_HEADER. UseAspNetCoreSharedServer sends it:

dotnet add package AspNetCoreSharedServer.Middleware
var app = builder.Build();

app.UseAspNetCoreSharedServer();

That is all. Kestrel must also listen with HTTP/3 enabled on the HTTPS port it is given in ASPNETCORE_URLS:

builder.WebHost.UseKestrel(options =>
{
    options.ListenAnyIP(httpsPort, listenOptions =>
    {
        listenOptions.UseHttps();
        listenOptions.Protocols = HttpProtocols.Http1AndHttp2AndHttp3;
    });
});
  • The value is read once, when the pipeline is built.
  • Outside AspNetCoreSharedServer, or when it does not forward HTTP/3 for the application (HTTP/3 switched off, no https URL, or a PROXY header enabled), the variable is empty and UseAspNetCoreSharedServer adds nothing, so it is safe to leave in.
  • The header is set with a plain assignment, so there is never a second Alt-Svc header.

PROXY protocol (builder.WebHost.UseAspNetCoreSharedServer())

With EnableProxyHeader or EnableProxyV2Header, AspNetCoreSharedServer starts every TCP connection to your application with a PROXY header, so that the application can see the real address of the client, and sets the environment variable PROXY_PROTOCOL to v1 or v2. When that variable is set, UseAspNetCoreSharedServer on the web host turns on Scintillating.ProxyProtocol.Middleware (a dependency of this package) for every Kestrel endpoint. HttpContext.Connection.RemoteIpAddress is then the real client.

var builder = WebApplication.CreateBuilder(args);

builder.WebHost.UseAspNetCoreSharedServer();   // before UseKestrel / ConfigureKestrel
builder.WebHost.UseKestrel(options => { ... });
  • Call it before the Kestrel endpoints are created: it applies to the endpoints that are created after it.
  • The header is read before TLS, so it works together with UseHttps.
  • When the variable is not set, nothing changes. When it is set, every connection must carry the header; Kestrel refuses the others. Behind AspNetCoreSharedServer that is always the case, but a port cannot serve both kinds of connection.
  • HTTP/3 is not forwarded when a PROXY header is enabled, because the PROXY protocol only exists for TCP.
  • This part needs .NET 8 or newer (a requirement of Scintillating.ProxyProtocol.Middleware).

See the AspNetCoreSharedServer documentation for how HTTP/3 is forwarded.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.2.1 87 11/12/2026
4.2.0 85 11/12/2026
4.1.1 105 11/4/2026
4.1.0 100 11/2/2026
4.0.2 106 10/28/2026
4.0.1 109 10/28/2026
4.0.0 104 10/28/2026