DeviceDetector.NET 3.8.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package DeviceDetector.NET --version 3.8.1
NuGet\Install-Package DeviceDetector.NET -Version 3.8.1
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="DeviceDetector.NET" Version="3.8.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DeviceDetector.NET --version 3.8.1
#r "nuget: DeviceDetector.NET, 3.8.1"
#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.
// Install DeviceDetector.NET as a Cake Addin
#addin nuget:?package=DeviceDetector.NET&version=3.8.1

// Install DeviceDetector.NET as a Cake Tool
#tool nuget:?package=DeviceDetector.NET&version=3.8.1

DeviceDetector.NET

GitHub stars Awesome Build status Join the chat at https://gitter.im/totpero/DeviceDetector.NET Code Health HitCount

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
DeviceDetector.SetVersionTruncation(VersionTruncation.VERSION_TRUNCATION_NONE);

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
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.GetDevice();
	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

More details here...

Product Compatible and additional computed target framework versions.
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on DeviceDetector.NET:

Package Downloads
OneLine

OneLine is an abstraction standardized redefined framework.

H.Necessaire.Runtime The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

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

Yaroslav08.Extensions

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.3.3 7,944 3/19/2024
6.3.2 113 3/19/2024
6.3.1 37,199 2/29/2024
6.3.0 5,206 2/19/2024
6.2.0 78,889 1/3/2024
6.1.4 271,164 8/7/2023
6.1.0 165,736 3/5/2023
4.3.2 185,164 10/24/2022
4.3.1 1,185 10/24/2022
4.3.0 775,998 8/8/2021
4.2.0 497,509 7/26/2020
4.1.0 281,363 8/26/2019
4.0.0 28,584 7/5/2019
3.11.6 20,705 4/25/2019
3.11.4 73,424 12/31/2018
3.11.2 12,065 11/4/2018
3.9.2.2 20,210 2/28/2018
3.9.2.1 2,015 2/28/2018
3.9.2 2,099 2/9/2018
3.9.1 1,841 2/1/2018
3.8.1 3,536 1/29/2018