DeviceDetector.NET
4.3.1
See the version list below for details.
dotnet add package DeviceDetector.NET --version 4.3.1
NuGet\Install-Package DeviceDetector.NET -Version 4.3.1
<PackageReference Include="DeviceDetector.NET" Version="4.3.1" />
paket add DeviceDetector.NET --version 4.3.1
#r "nuget: DeviceDetector.NET, 4.3.1"
// Install DeviceDetector.NET as a Cake Addin #addin nuget:?package=DeviceDetector.NET&version=4.3.1 // Install DeviceDetector.NET as a Cake Tool #tool nuget:?package=DeviceDetector.NET&version=4.3.1
DeviceDetector.NET
Description
The Universal Device Detection library for .NET that parses User Agents and detects devices (desktop, tablet, mobile, tv, cars, console, etc.), clients (browsers, feed readers, media players, PIMs, ...), operating systems, brands and models. This is a port of the popular PHP device-detector library to C#. For the most part you can just follow the documentation for device-detector with no issue.
Usage
Using DeviceDetector.NET with nuget is quite easy. Just add DeviceDetector.NET to your projects requirements. And use some code like this one:
using DeviceDetectorNET;
// OPTIONAL: Set version truncation to none, so full versions will be returned
// By default only minor versions will be returned (e.g. X.Y)
// for other options see VERSION_TRUNCATION_* constants in DeviceParserAbstract class
// add using DeviceDetectorNET.Parser;
DeviceDetector.SetVersionTruncation(VersionTruncation.VERSION_TRUNCATION_NONE);
var dd = new DeviceDetector(userAgent);
// OPTIONAL: Set caching method
// By default static cache is used, which works best within one php process (memory array caching)
// To cache across requests use caching in files or memcache
// add using DeviceDetectorNET.Cache;
dd.SetCache(new DictionaryCache());
// OPTIONAL: If called, GetBot() will only return true if a bot was detected (speeds up detection a bit)
dd.DiscardBotInformation();
// OPTIONAL: If called, bot detection will completely be skipped (bots will be detected as regular devices then)
dd.SkipBotDetection();
dd.Parse();
if(dd.IsBot()) {
// handle bots,spiders,crawlers,...
var botInfo = dd.GetBot();
} else {
var clientInfo = dd.GetClient(); // holds information about browser, feed reader, media player, ...
var osInfo = dd.GetOs();
var device = dd.GetDeviceName();
var brand = dd.GetBrandName();
var model = dd.GetModel();
}
Instead of using the full power of DeviceDetector it might in some cases be better to use only specific parsers. If you aim to check if a given useragent is a bot and don't require any of the other information, you can directly use the bot parser.
using DeviceDetectorNET.Parser;
var botParser = new BotParser();
botParser.SetUserAgent(userAgent);
// OPTIONAL: discard bot information. Parse() will then return true instead of information
botParser.DiscardDetails = true;
var result = botParser.Parse();
if (result != null) {
// do not do anything if a bot is detected
return;
}
// handle non-bot requests
The default regexes directory path can be changed like this:
DeviceDetectorSettings.RegexesDirectory = @"C:\YamlRegexsFiles\";
.....
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.1
- LiteDB (>= 5.0.12)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.1)
- Newtonsoft.Json (>= 13.0.1)
- semver (>= 2.2.0)
- YamlDotNet (>= 11.2.1)
-
.NETStandard 2.0
- LiteDB (>= 5.0.12)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.1)
- Newtonsoft.Json (>= 13.0.1)
- semver (>= 2.2.0)
- YamlDotNet (>= 11.2.1)
NuGet packages (8)
Showing the top 5 NuGet packages that depend on DeviceDetector.NET:
Package | Downloads |
---|---|
Volo.Abp.AspNetCore
Package Description |
|
OneLine
OneLine is an abstraction standardized redefined framework. |
|
H.Necessaire.Runtime
A Core Framework for Rapid Application Development |
|
OneLine.Common
OneLine.Common is a project that can be used on a server backend as well on client side application that support net standard like xamarin or blazor. |
|
uMarketingSuite.Core
The all-in-one marketing solution for the Umbraco CMS - assemblies only |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on DeviceDetector.NET:
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.
|
|
go2ismail/Asp.Net-Core-Inventory-Order-Management-System
ASP.NET Core Razor Pages implementation of inventory order management. Warehouse, product, vendor, customer, purchase order, sales order, shipment, goods receive and more
|
Version | Downloads | Last updated |
---|---|---|
6.3.3 | 473,127 | 3/19/2024 |
6.3.2 | 235 | 3/19/2024 |
6.3.1 | 46,996 | 2/29/2024 |
6.3.0 | 19,835 | 2/19/2024 |
6.2.0 | 95,811 | 1/3/2024 |
6.1.4 | 372,718 | 8/7/2023 |
6.1.0 | 216,871 | 3/5/2023 |
4.3.2 | 200,554 | 10/24/2022 |
4.3.1 | 1,267 | 10/24/2022 |
4.3.0 | 855,730 | 8/8/2021 |
4.2.0 | 539,434 | 7/26/2020 |
4.1.0 | 287,453 | 8/26/2019 |
4.0.0 | 30,964 | 7/5/2019 |
3.11.6 | 24,048 | 4/25/2019 |
3.11.4 | 79,778 | 12/31/2018 |
3.11.2 | 12,906 | 11/4/2018 |
3.9.2.2 | 20,465 | 2/28/2018 |
3.9.2.1 | 2,112 | 2/28/2018 |
3.9.2 | 2,223 | 2/9/2018 |
3.9.1 | 1,936 | 2/1/2018 |
3.8.1 | 4,144 | 1/29/2018 |