Soenneker.Extensions.HttpContext 11.0.779

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Extensions.HttpContext --version 11.0.779
                    
NuGet\Install-Package Soenneker.Extensions.HttpContext -Version 11.0.779
                    
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="Soenneker.Extensions.HttpContext" Version="11.0.779" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Extensions.HttpContext" Version="11.0.779" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Extensions.HttpContext" />
                    
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 Soenneker.Extensions.HttpContext --version 11.0.779
                    
#r "nuget: Soenneker.Extensions.HttpContext, 11.0.779"
                    
#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 Soenneker.Extensions.HttpContext@11.0.779
                    
#: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=Soenneker.Extensions.HttpContext&version=11.0.779
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Extensions.HttpContext&version=11.0.779
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Extensions.HttpContext

Small ASP.NET Core helpers for local-request checks, Basic authentication challenges, and proxy-aware client IP lookup.

Installation

dotnet add package Soenneker.Extensions.HttpContext

Identify local requests

using Soenneker.Extensions.HttpContext;

if (httpContext.IsLocalRequest())
{
    // Apply behavior intended only for requests from this host.
}

IsLocalRequest() returns true when the remote address is loopback, matches the local connection address, or both addresses are absent. It returns false when only the remote address is absent. It examines the connection addresses after any middleware that may have rewritten them.

Return a Basic authentication challenge

httpContext.SetUnauthorized();
return;

SetUnauthorized() sets status code 401 and adds WWW-Authenticate: Basic unless a challenge header already exists. It does not write a response body or end request processing, so return from the endpoint or middleware after calling it.

Read the client IP

string? clientIp = httpContext.GetRequestIp();

The lookup order is:

  1. A valid IP address in CF-Connecting-IP.
  2. The first address in X-Forwarded-For, when it is a valid IP address.
  3. HttpContext.Connection.RemoteIpAddress.

Forwarding headers are supplied by the caller and can be spoofed unless your edge proxy removes incoming copies and writes trusted values. Only use the returned forwarded address for authorization, rate limiting, or auditing when that trust boundary is enforced. In standard ASP.NET Core deployments, prefer configuring Forwarded Headers Middleware and then reading RemoteIpAddress directly when possible.

Malformed or blank forwarding values are ignored. If no usable address is available, GetRequestIp() returns null.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Soenneker.Extensions.HttpContext:

Package Downloads
Soenneker.Swashbuckle.Authentication

A middleware implementing basic authentication and RBAC support for Swashbuckle (Swagger)

Soenneker.Hangfire.BasicAuthentication

Protects the Hangfire dashboard with PBKDF2-backed HTTP Basic authentication

Soenneker.Extensions.IHttpContextAccessors

A collection of helpful IHttpContextAccessor extension methods

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.783 73 11/3/2026
11.0.782 66 11/3/2026
11.0.781 76 11/2/2026
11.0.780 372 10/27/2026
11.0.779 197 10/26/2026
11.0.778 210 10/26/2026
4.0.777 537 10/15/2026
4.0.776 116 10/14/2026
4.0.775 157 10/14/2026
4.0.774 175 10/14/2026
4.0.772 107 10/14/2026
4.0.766 143 10/13/2026
4.0.765 133 10/12/2026
4.0.763 162 10/12/2026
4.0.762 104 10/12/2026
4.0.761 205 10/11/2026
4.0.760 133 10/11/2026
4.0.759 106 10/11/2026
4.0.758 189 10/11/2026
4.0.757 421 9/30/2026
Loading failed

Enable runtime async for compatible .NET 11 projects