HttpLens.Dashboard 1.3.0

dotnet add package HttpLens.Dashboard --version 1.3.0
                    
NuGet\Install-Package HttpLens.Dashboard -Version 1.3.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="HttpLens.Dashboard" Version="1.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HttpLens.Dashboard" Version="1.3.0" />
                    
Directory.Packages.props
<PackageReference Include="HttpLens.Dashboard" />
                    
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 HttpLens.Dashboard --version 1.3.0
                    
#r "nuget: HttpLens.Dashboard, 1.3.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 HttpLens.Dashboard@1.3.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=HttpLens.Dashboard&version=1.3.0
                    
Install as a Cake Addin
#tool nuget:?package=HttpLens.Dashboard&version=1.3.0
                    
Install as a Cake Tool

HttpLens.Dashboard

The embedded web dashboard for HttpLens — a browser-based UI for inspecting all outbound HTTP traffic captured by HttpLens.Core.

Most users should install the HttpLens meta-package, which bundles both HttpLens.Core and HttpLens.Dashboard. Install HttpLens.Dashboard directly only if you're building a custom setup.

Installation

dotnet add package HttpLens.Dashboard

This package depends on HttpLens.Core and will pull it in automatically.

What's Inside

Component Description
Embedded SPA A dark/light theme single-page application served from embedded resources — no external files needed
Traffic API RESTful JSON endpoints for listing, filtering, and exporting captured HTTP traffic
Export endpoints One-click export as cURL, C# HttpClient code, or HAR 1.2 files
Dashboard middleware Serves index.html, CSS, and JS bundles directly from the NuGet package
SignalR hub Pushes new traffic records in real-time to connected dashboard clients

Quick Start

var builder = WebApplication.CreateBuilder(args);

// 1. Register HttpLens services
builder.Services.AddHttpLens();

// 2. Allow synchronous IO (required for embedded resource serving)
builder.WebHost.ConfigureKestrel(options => options.AllowSynchronousIO = true);

var app = builder.Build();

// 3. Mount the dashboard
app.MapHttpLensDashboard();

app.Run();

Then open https://localhost:5001/_httplens in your browser.

Dashboard Features

🔍 Traffic Table

  • Real-time list of all captured HTTP requests/responses
  • Color-coded status codes (2xx green, 4xx orange, 5xx red)
  • Sortable by timestamp, method, status, duration
  • Search and filter by method, status code, host, or free text

🔎 Filter Bar

The dashboard includes a visual filter bar for quickly narrowing traffic:

  • Method dropdown — filter by GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
  • Status dropdown — filter by 2xx, 3xx, 4xx, 5xx status code classes
  • Host input — substring match on the request URL (e.g., "github.com")
  • Search input — free-text case-insensitive URL search
  • Clear Filters button — reset all filters with one click

Filters are applied both client-side (instant) and server-side (on API calls).

📋 Detail Panel

Click any row to see the full details:

  • Request tab — Method, URI, headers, body (with syntax highlighting for JSON)
  • Response tab — Status code, headers, body
  • Headers tab — Combined request + response headers with sensitive values masked
  • Timing tab — Total duration
  • Correlation tab — W3C Trace ID, Parent Span ID, inbound request path, HttpClient name
  • Export tab — Copy as cURL or C# code with one click

🔄 Polly Retry Grouping

Retry attempts are grouped visually — the first attempt appears as a normal row, subsequent retries appear indented beneath it with attempt numbers.

📦 HAR Export

Download all captured traffic (or filtered results) as a HAR 1.2 file, importable in Chrome DevTools, Firefox, or any HAR viewer.

🌙 Dark / Light Theme

Toggle between dark and light themes using the button in the header. Preference is saved to localStorage.

API Endpoints

All endpoints are served under the dashboard base path (default: /_httplens):

Endpoint Method Description
/_httplens/api/traffic?skip=0&take=100 GET List traffic records with pagination
/_httplens/api/traffic?method=GET&status=2&host=example.com&search=api GET List with server-side filtering
/_httplens/api/traffic/{id} GET Get a single record by ID
/_httplens/api/traffic DELETE Clear all stored records
/_httplens/api/traffic/retrygroup/{groupId} GET Get all attempts in a retry group
/_httplens/api/traffic/{id}/export/curl GET Export a record as a cURL command
/_httplens/api/traffic/{id}/export/csharp GET Export a record as C# HttpClient code
/_httplens/api/traffic/export/har?ids=... GET Export records as HAR 1.2 JSON
/_httplens/hub WebSocket/SignalR Live push channel for new traffic records

Traffic API Filter Parameters

Parameter Match Type Example Description
method Exact (case-insensitive) ?method=GET Filter by HTTP method
status Prefix ?status=4 Matches 400, 404, 429, etc.
host Substring (case-insensitive) ?host=github.com Filter by host in URL
search Substring (case-insensitive) ?search=api Free-text URL search

Filters are applied server-side before pagination. The total in the response reflects the filtered count.

Custom Dashboard Path

// Mount at a custom path
app.MapHttpLensDashboard("/my-custom-path");

// Dashboard available at: https://localhost:5001/my-custom-path
// API available at:       https://localhost:5001/my-custom-path/api/traffic

Security

Security is applied automatically by MapHttpLensDashboard() — no UseMiddleware calls are needed in your Program.cs. All security layers are opt-in; existing users who don't configure security see zero behavior change.

Middleware Execution Order

Checks run in this order; earlier layers short-circuit so later ones are skipped:

  1. EnabledGuard — returns 404 if IsEnabled = false
  2. IpAllowlist — returns 403 if client IP is not in AllowedIpRanges
  3. ApiKey — returns 401 if X-HttpLens-Key header or ?key= query param is missing or wrong
  4. Authorization policy — evaluated by ASP.NET Core auth middleware

API Key Authentication

When ApiKey is configured, the embedded SPA automatically reads ?key= from the page URL on load, stores it in sessionStorage, and injects it as an X-HttpLens-Key header on every API call. If a request returns 401, the UI displays a clear message.

Access the dashboard with the key in the URL:

/_httplens?key=my-secret

Subsequent navigation within the SPA does not require the query parameter — the key is kept in sessionStorage for the duration of the browser session.

Securing the Dashboard in Production

The recommended pattern for production use:

builder.Services.AddHttpLens(builder.Environment, options =>
{
    builder.Configuration.GetSection("HttpLens").Bind(options);
});

// Only map dashboard if services were registered
if (app.Services.GetService<ITrafficStore>() != null)
    app.MapHttpLensDashboard();

With appsettings.Production.json:

{
  "HttpLens": {
    "IsEnabled": true,
    "ApiKey": "my-production-secret",
    "AllowedIpRanges": ["10.0.0.0/8", "127.0.0.1"]
  }
}

IP Allowlist

Supports exact IPv4 addresses, exact IPv6 addresses, and CIDR notation. IPv4-mapped IPv6 addresses (e.g. ::ffff:127.0.0.1) are automatically normalised to their IPv4 equivalents before matching.

builder.Services.AddHttpLens(options =>
{
    options.AllowedIpRanges.AddRange(["127.0.0.1", "::1", "10.0.0.0/8", "192.168.1.0/24"]);
});

Authorization Policy

Apply any named ASP.NET Core authorization policy to all dashboard and API routes:

builder.Services.AddAuthorization(options =>
{
    options.AddPolicy("HttpLensAccess", policy =>
        policy.RequireRole("Admin"));
});

builder.Services.AddHttpLens(options =>
{
    options.AuthorizationPolicy = "HttpLensAccess";
});

The policy must be registered in the host application before MapHttpLensDashboard() is called.

Testing with WebApplicationFactory

When using Microsoft.AspNetCore.Mvc.Testing, enable synchronous IO on the TestServer:

public class MyTests : IClassFixture<WebApplicationFactory<Program>>
{
    private readonly HttpClient _client;

    public MyTests(WebApplicationFactory<Program> factory)
    {
        var customFactory = factory.WithWebHostBuilder(builder =>
        {
            builder.ConfigureTestServices(services =>
            {
                services.Configure<TestServerOptions>(options =>
                    options.AllowSynchronousIO = true);
            });
        });
        _client = customFactory.CreateClient();
    }

    [Fact]
    public async Task Dashboard_returns_html()
    {
        var response = await _client.GetAsync("/_httplens");
        Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        Assert.Contains("text/html", response.Content.Headers.ContentType?.ToString());
    }
}

Supported Frameworks

Framework Supported
.NET 8 ✅
.NET 9 ✅
.NET 10 ✅

License

MIT

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on HttpLens.Dashboard:

Package Downloads
HttpLens

HttpLens — install one NuGet, add two lines, see all outbound HTTP traffic in a browser dashboard.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.0 156 4/28/2026
1.2.0 134 4/20/2026
1.1.0 139 4/13/2026
1.0.0 152 4/5/2026