MyCSharp.HttpUserAgentParser 3.1.2

Requires NuGet 2.12 or higher.

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

MyCSharp.HttpUserAgentParser

Fast HTTP User-Agent parsing for .NET.

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

Install

dotnet add package MyCSharp.HttpUserAgentParser

Quick start (no DI)

string userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36";
HttpUserAgentInformation info = HttpUserAgentParser.Parse(userAgent);
// or: HttpUserAgentInformation.Parse(userAgent)

Dependency injection

If you want to inject a parser (e.g., in ASP.NET Core), use IHttpUserAgentParserProvider.

No cache

services
	.AddHttpUserAgentParser();

ConcurrentDictionary cache

services
	.AddHttpUserAgentCachedParser();
// or: .AddHttpUserAgentParser<HttpUserAgentParserCachedProvider>();

Telemetry (EventCounters)

Telemetry is:

  • Opt-in: disabled by default (keeps hot path overhead-free)
  • Low overhead: counters are only written when a listener is attached

Enable telemetry (Fluent API)

services
	.AddHttpUserAgentParser()
	.WithTelemetry();

EventSource + counters

EventSource: MyCSharp.HttpUserAgentParser (constant: HttpUserAgentParserEventSource.EventSourceName)

  • parse.requests (incrementing)
  • parse.duration (ms, event counter)
  • cache.hit (incrementing)
  • cache.miss (incrementing)
  • cache.size (polling)

Monitor with dotnet-counters

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

Telemetry (native Meters)

In addition to EventCounters, this package can emit native System.Diagnostics.Metrics instruments.

Telemetry is:

  • Opt-in: disabled by default (keeps hot path overhead-free)
  • Low overhead: measurements are only recorded when enabled

Enable meters (Fluent API)

services
	.AddHttpUserAgentParser()
	.WithMeterTelemetry();

Meter + instruments

Meter: MyCSharp.HttpUserAgentParser (constant: HttpUserAgentParserMeters.MeterName)

  • parse.requests (counter)
  • parse.duration (histogram, ms)
  • cache.hit (counter)
  • cache.miss (counter)
  • cache.size (observable gauge)

Export to OpenTelemetry

You can collect these EventCounters via OpenTelemetry metrics and export them (OTLP, Prometheus, Azure Monitor, …).

Packages you typically need:

  • OpenTelemetry
  • OpenTelemetry.Exporter.OpenTelemetryProtocol (or another exporter)
  • OpenTelemetry.Instrumentation.EventCounters

Example (minimal):

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

builder.Services.AddOpenTelemetry()
	.WithMetrics(metrics =>
	{
		metrics
			.AddEventCountersInstrumentation(options =>
			{
				options.AddEventSources(HttpUserAgentParserEventSource.EventSourceName);
			})
			.AddOtlpExporter();
	});

If you also use the MemoryCache/AspNetCore packages, add their EventSource names too.

Export native meters to OpenTelemetry

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

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

builder.Services.AddOpenTelemetry()
	.WithMetrics(metrics =>
	{
		metrics
			.AddMeter(HttpUserAgentParserMeters.MeterName)
			.AddOtlpExporter();
	});

Export to Application Insights

There are two common approaches:

Collect with OpenTelemetry (see above) and export to Azure Monitor / Application Insights using an Azure Monitor exporter. This keeps your pipeline consistent and avoids custom listeners.

Typical packages (names may differ by version):

  • OpenTelemetry
  • OpenTelemetry.Instrumentation.EventCounters
  • Azure.Monitor.OpenTelemetry.Exporter

2) Custom EventListener → TelemetryClient

If you prefer a direct listener, you can attach an EventListener and forward values as custom metrics.

High-level idea:

  • Enable the EventSource
  • Parse the EventCounters payload
  • Track as Application Insights metrics

Notes:

  • This is best-effort telemetry (caches can race)
  • Keep aggregation intervals reasonable (e.g. 10s)
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 (13)

Showing the top 5 NuGet packages that depend on MyCSharp.HttpUserAgentParser:

Package Downloads
Volo.Abp.AspNetCore

Package Description

MyCSharp.HttpUserAgentParser.AspNetCore

HTTP User Agent Parser Extensions for ASP.NET Core

ZhileTime.Hope.AspNetCore

Package Description

MyCSharp.HttpUserAgentParser.MemoryCache

HTTP User Agent Parser Extensions for IMemoryCache

PostalApiClient

Api client for mail delivery platform Postal

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on MyCSharp.HttpUserAgentParser:

Repository Stars
abpframework/abp
Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
Version Downloads Last Updated
3.1.2 211 2/19/2026
3.0.28 260,993 8/25/2025
3.0.27 694 8/23/2025
3.0.25 547,286 4/26/2025
3.0.23 15,432 4/12/2025
3.0.13 45,383 2/25/2025
3.0.12 570 2/25/2025
3.0.11 39,170 1/25/2025
3.0.10 21,538 1/14/2025
3.0.9 102,597 11/12/2024
3.0.8 12,390 11/1/2024
Loading failed