-
Notifications
You must be signed in to change notification settings - Fork 73
Home
DeviceDetector.NET is the universal device detection library for .NET. It parses HTTP User-Agent strings (and, optionally, User-Agent Client Hints) to detect:
- Devices — desktop, smartphone, tablet, phablet, TV, console, car browser, camera, portable media player, wearable, smart display, smart speaker, peripheral
- Clients — browsers, feed readers, media players, mobile apps, PIMs, libraries
- Operating systems — name, version, family
- Bots — crawlers, spiders, monitoring tools
- Brands and models — for mobile/hardware devices
It is a faithful port of the popular PHP library matomo-org/device-detector, tracked as a git submodule (device-detector) so the regex rule set stays in sync with upstream. For most detection questions ("why wasn't X detected as Y"), the upstream PHP documentation and issue tracker apply directly — the rules themselves are shared, only the code that executes them differs.
| I want to... | Go to |
|---|---|
| Add the library to my project and parse my first User-Agent | Getting Started |
Check Is*() helpers (IsSmartphone, IsBrowser, ...) |
Device and Client Type Checks |
| Use Client Hints instead of / together with User-Agent | Client Hints |
| Speed up repeated parsing with caching | Caching |
| Use a PCRE-compatible regex engine for better upstream YAML compatibility | Regex Engines |
| Detect bots without paying for full parsing | Bot Detection |
Use it in ASP.NET Core app logic (DI, IsMobile() per request) |
ASP.NET Core Integration |
| Render an icon (browser/OS/brand/device) next to a detection result | Icon Packs |
| Enrich ASP.NET Core logs with device info | Serilog.Enrichers.AspNetCore.DeviceDetector |
| Pre-warm a cache database for known User-Agents | CacheBuilder Tool |
| Update the bundled detection rules from the PHP project | Updating Device Detector Data |
| Report a bug or send a pull request | Contributing |
| Something isn't detected correctly | FAQ |
-
DeviceDetector.NET— the core library (NuGet packageDeviceDetector.NET) -
DeviceDetector.NET.RegexEngine.PCRE— optional PCRE.NET-backed regex engine -
DeviceDetector.NET.CacheBuilder— CLI tool to pre-build a parse-result cache -
DeviceDetector.NET.Web— minimal ASP.NET Core demo API -
src/Icons— icon-path resolver packages:DeviceDetector.NET.Icons(Simbiat pack convention),DeviceDetector.NET.Icons.Matomo(official matomo-icons convention),DeviceDetector.NET.Icons.Common(shared primitives) — see Icon Packs -
Serilog.Enrichers.AspNetCore.DeviceDetector— Serilog enricher that attaches device info to log events, with its own...Testsproject -
DeviceDetector.NET.Tests— xUnit + Shouldly test suite, mirrors upstream PHP fixtures -
device-detector— git submodule pointing at the upstream PHP project (source of truth for YAML regex rules)
DeviceDetector.NET is licensed under the Apache License 2.0 — see LICENSE. Note that the upstream PHP project it ports (matomo-org/device-detector) is licensed under LGPL v3 or later; if you redistribute the vendored YAML rule data itself, check compliance with the upstream license as well.
DeviceDetector.NET is a .NET port of matomo-org/device-detector · Licensed under Apache 2.0 · Report an issue