HttpLens 1.1.0
dotnet add package HttpLens --version 1.1.0
NuGet\Install-Package HttpLens -Version 1.1.0
<PackageReference Include="HttpLens" Version="1.1.0" />
<PackageVersion Include="HttpLens" Version="1.1.0" />
<PackageReference Include="HttpLens" />
paket add HttpLens --version 1.1.0
#r "nuget: HttpLens, 1.1.0"
#:package HttpLens@1.1.0
#addin nuget:?package=HttpLens&version=1.1.0
#tool nuget:?package=HttpLens&version=1.1.0
HttpLens
Install one NuGet package, add two lines of code, and see every outbound HTTP call your app makes — in a browser dashboard.
Features
- Automatic interception — captures all
HttpClientrequests/responses viaIHttpClientFactory - Embedded dashboard — dark/light theme SPA served at
/_httplens - Sensitive header masking — Authorization, Cookie, X-Api-Key and custom headers masked before storage
- Request/response body capture — with configurable size limits and truncation
- Polly retry detection — groups retry attempts visually in the dashboard
- Export — one-click copy as cURL or C#
HttpClientcode; download HAR 1.2 files - Correlation — W3C Trace ID, inbound request path, HttpClient name
- In-memory ring buffer — configurable max records, thread-safe
- Real-time updates — polling fallback (SignalR planned)
Installation
dotnet add package HttpLens
Quick Start
var builder = WebApplication.CreateBuilder(args);
// 1. Register HttpLens services
builder.Services.AddHttpLens();
var app = builder.Build();
// 2. Mount the dashboard
app.MapHttpLensDashboard();
app.Run();
Then open https://localhost:5001/_httplens in your browser.
Configuration
| Option | Default | Description |
|---|---|---|
MaxStoredRecords |
500 |
Maximum number of records kept in memory |
MaxBodyCaptureSize |
64000 |
Max characters captured per body |
DashboardPath |
/_httplens |
URL path for the dashboard |
SensitiveHeaders |
Authorization, Cookie, Set-Cookie, X-Api-Key |
Headers whose values are masked |
CaptureRequestBody |
true |
Whether to capture request bodies |
CaptureResponseBody |
true |
Whether to capture response bodies |
builder.Services.AddHttpLens(options =>
{
options.MaxStoredRecords = 1000;
options.SensitiveHeaders.Add("X-Custom-Secret");
options.CaptureRequestBody = true;
});
Security
By default HttpLens applies no security — the dashboard is publicly accessible. This preserves the zero-config developer experience. Each security layer is opt-in.
Security Layers
| Layer | Option | Default | Behaviour |
|---|---|---|---|
| Master switch | IsEnabled |
true |
When false, capture stops and dashboard returns 404 |
| Environment guard | AllowedEnvironments |
[] (all) |
Only register services in matching environments |
| API key | ApiKey |
null (off) |
Require X-HttpLens-Key header or ?key= query param |
| IP allowlist | AllowedIpRanges |
[] (all) |
Restrict by IP address or CIDR range |
| Auth policy | AuthorizationPolicy |
null (off) |
Apply any registered ASP.NET Core auth policy |
Configuration Examples
Restrict to development only:
// Automatically skips registration in Production
builder.Services.AddHttpLens(builder.Environment, options =>
{
options.AllowedEnvironments.AddRange(["Development", "Staging"]);
});
Protect with an API key:
builder.Services.AddHttpLens(options =>
{
options.ApiKey = "my-secret-key";
});
Then access the dashboard at /_httplens?key=my-secret-key. The key is stored in sessionStorage so subsequent API calls include it automatically via the X-HttpLens-Key header.
Restrict by IP:
builder.Services.AddHttpLens(options =>
{
options.AllowedIpRanges.AddRange(["127.0.0.1", "10.0.0.0/8", "::1"]);
});
Disable in production via appsettings.json:
appsettings.Development.json:
{ "HttpLens": { "IsEnabled": true } }
appsettings.Production.json:
{ "HttpLens": { "IsEnabled": false } }
Then bind in Program.cs:
builder.Services.AddHttpLens(options =>
builder.Configuration.GetSection("HttpLens").Bind(options));
Combined example (recommended for shared/staging environments):
builder.Services.AddHttpLens(builder.Environment, options =>
{
builder.Configuration.GetSection("HttpLens").Bind(options);
// Override: force-disable in production regardless of config
if (builder.Environment.IsProduction())
options.IsEnabled = false;
});
Middleware Order
Security checks are applied automatically inside MapHttpLensDashboard() in this order:
- EnabledGuard — returns 404 if
IsEnabled = false - IpAllowlist — returns 403 if client IP is not in
AllowedIpRanges - ApiKey — returns 401 if
X-HttpLens-Key/?key=is missing or wrong - Authorization policy — evaluated by ASP.NET Core auth middleware
- Endpoint handler
No UseMiddleware calls are needed in your Program.cs.
Note:
MapHttpLensDashboard()automatically applies all security checks (enabled guard, IP allowlist, API key, and authorization policy) to both the SPA and API routes. If you callMapHttpLensApi()directly, only theauthorizationPolicyparameter (if provided) is applied — IP allowlist and API key checks are skipped.
Polly Retry Detection
To group Polly retry attempts in the dashboard:
builder.Services
.AddHttpClient("MyClient")
.AddStandardResilienceHandler() // Polly resilience
.Services
.AddHttpClient("MyClient")
.AddRetryDetection(); // HttpLens retry tracking
Retried requests are grouped visually — the first attempt appears as a normal row, subsequent retries appear indented beneath it.
Export Features
- cURL — Click "📋 Copy" on the Export tab to copy a ready-to-paste cURL command
- C# — Copy a complete
HttpClient/HttpRequestMessagecode snippet - HAR — Click "📦 HAR" to download all filtered traffic as a HAR 1.2 file (importable in Chrome DevTools)
Dark / Light Theme
Toggle between dark and light themes using the 🌙/☀️ button in the header. Preference is saved to localStorage.
API Endpoints
| Endpoint | Description |
|---|---|
GET /_httplens/api/traffic?skip=0&take=100 |
List traffic records |
GET /_httplens/api/traffic/{id} |
Get single record |
DELETE /_httplens/api/traffic |
Clear all records |
GET /_httplens/api/traffic/retrygroup/{groupId} |
Get all attempts in a retry group |
GET /_httplens/api/traffic/{id}/export/curl |
Export as cURL |
GET /_httplens/api/traffic/{id}/export/csharp |
Export as C# code |
GET /_httplens/api/traffic/export/har?ids=... |
Export as HAR 1.2 |
License
MIT
| Product | Versions 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. |
-
net10.0
- HttpLens.Core (>= 1.1.0)
- HttpLens.Dashboard (>= 1.1.0)
-
net8.0
- HttpLens.Core (>= 1.1.0)
- HttpLens.Dashboard (>= 1.1.0)
-
net9.0
- HttpLens.Core (>= 1.1.0)
- HttpLens.Dashboard (>= 1.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.