Soenneker.Extensions.HttpContext 11.0.790

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.790
                    
NuGet\Install-Package Soenneker.Extensions.HttpContext -Version 11.0.790
                    
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.790" />
                    
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.790" />
                    
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.790
                    
#r "nuget: Soenneker.Extensions.HttpContext, 11.0.790"
                    
#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.790
                    
#: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.790
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Extensions.HttpContext&version=11.0.790
                    
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.794 321 11/18/2026
11.0.792 118 11/18/2026
11.0.791 209 11/15/2026
11.0.790 215 11/11/2026
11.0.789 220 11/11/2026
11.0.788 175 11/11/2026
11.0.787 111 11/11/2026
11.0.786 116 11/11/2026
11.0.785 100 11/11/2026
11.0.784 187 11/10/2026
11.0.783 510 11/3/2026
11.0.782 141 11/3/2026
11.0.781 154 11/2/2026
11.0.780 394 10/27/2026
11.0.779 212 10/26/2026
11.0.778 225 10/26/2026
4.0.777 635 10/15/2026
4.0.776 131 10/14/2026
4.0.775 171 10/14/2026
4.0.774 187 10/14/2026
Loading failed

Updated Multiple NuGet packages