Skip to main content

HTTP User Agent Parser Extensions for ASP.NET Core

Total Downloads
890.1K
890,090
Published
Apr 1, 2026
7mo ago

Get Started

dotnet add package MyCSharp.HttpUserAgentParser.AspNetCore --version 3.1.6
ProductVersions
.NET
net10.0net8.0net9.0

README

MyCSharp.HttpUserAgentParser.AspNetCore

ASP.NET Core integration for MyCSharp.HttpUserAgentParser.

Repository: https://github.com/mycsharp/HttpUserAgentParser

Install

dotnet add package MyCSharp.HttpUserAgentParser.AspNetCore

Quick start

Register a provider (any of the available ones) and then add the accessor:

The accessor pattern reads the User-Agent header from the current HttpContext and parses it using the registered provider.

services
	.AddHttpUserAgentMemoryCachedParser() // or: AddHttpUserAgentParser / AddHttpUserAgentCachedParser
	.AddHttpUserAgentParserAccessor();

Usage:

public sealed class MyController(IHttpUserAgentParserAccessor accessor)
{
	public HttpUserAgentInformation Get() => accessor.Get();
}

Just read the header

If you only want the raw User-Agent string:

string? ua = HttpContext.GetUserAgentString();

Telemetry (EventCounters)

Telemetry is modular and opt-in.

Enable (Fluent API)

services
	.AddHttpUserAgentParserAccessor()
	.WithAspNetCoreTelemetry();

The accessor registration returns the same options object, so you can chain this after any parser registration.

EventSource + counters

EventSource: MyCSharp.HttpUserAgentParser.AspNetCore (constant: HttpUserAgentParserAspNetCoreEventSource.EventSourceName)

  • user_agent.present (incrementing)
  • user_agent.missing (incrementing)

Monitor with dotnet-counters

dotnet-counters monitor --process-id <pid> MyCSharp.HttpUserAgentParser.AspNetCore

Telemetry (native Meters)

This package can also emit native System.Diagnostics.Metrics instruments.

Enable meters (Fluent API)

services
	.AddHttpUserAgentParserAccessor()
	.WithAspNetCoreMeterTelemetry();

Meter + instruments

Meter: MyCSharp.HttpUserAgentParser.AspNetCore (constant: HttpUserAgentParserAspNetCoreMeters.MeterName)

  • user_agent.present (counter)
  • user_agent.missing (counter)

Export to OpenTelemetry / Application Insights

Collect via OpenTelemetry EventCounters instrumentation:

using OpenTelemetry.Metrics;

metrics.AddEventCountersInstrumentation(options =>
{
	options.AddEventSources(HttpUserAgentParserAspNetCoreEventSource.EventSourceName);
});

Then export using your preferred exporter (OTLP, Prometheus, Azure Monitor / Application Insights, …).

Export native meters to OpenTelemetry

If you enabled native meters (see above), collect them via AddMeter(...):

using OpenTelemetry.Metrics;
using MyCSharp.HttpUserAgentParser.AspNetCore.Telemetry;

metrics.AddMeter(HttpUserAgentParserAspNetCoreMeters.MeterName);

Downloads by Version

Similar & Alternative Packages

Hand-picked matching NuGet libraries based on tags & ecosystem

Depended On By

Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

Compatibility metadata lists 3 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.