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
<PackageReference Include="MyCSharp.HttpUserAgentParser" Version="3.1.2" />
<PackageVersion Include="MyCSharp.HttpUserAgentParser" Version="3.1.2" />
<PackageReference Include="MyCSharp.HttpUserAgentParser" />
paket add MyCSharp.HttpUserAgentParser --version 3.1.2
#r "nuget: MyCSharp.HttpUserAgentParser, 3.1.2"
#:package MyCSharp.HttpUserAgentParser@3.1.2
#addin nuget:?package=MyCSharp.HttpUserAgentParser&version=3.1.2
#tool nuget:?package=MyCSharp.HttpUserAgentParser&version=3.1.2
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:
OpenTelemetryOpenTelemetry.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:
1) Recommended: OpenTelemetry → Application Insights
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):
OpenTelemetryOpenTelemetry.Instrumentation.EventCountersAzure.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
EventCounterspayload - Track as Application Insights metrics
Notes:
- This is best-effort telemetry (caches can race)
- Keep aggregation intervals reasonable (e.g. 10s)
| 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
-
net8.0
-
net9.0
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 | 231 | 2/19/2026 |
| 3.0.28 | 262,918 | 8/25/2025 |
| 3.0.27 | 698 | 8/23/2025 |
| 3.0.25 | 549,377 | 4/26/2025 |
| 3.0.23 | 15,456 | 4/12/2025 |
| 3.0.13 | 45,419 | 2/25/2025 |
| 3.0.12 | 573 | 2/25/2025 |
| 3.0.11 | 39,221 | 1/25/2025 |
| 3.0.10 | 21,572 | 1/14/2025 |
| 3.0.9 | 102,698 | 11/12/2024 |
| 3.0.8 | 12,394 | 11/1/2024 |