Welche Auswertungen bietet mir die Asp.Net Core Wangkanai.Detection?
Aufgabe:
Ich möchte in asp.Net Core 2 zur Laufzeit im Server Controller ermitteln, ob der Client-Browser ein Mobile-Device ist, damit die Oberfläche des Rückgabe-Views vorab angepasst werden kann.
Nuget Package
Wangkanai.Detection (kostenlos)
ASP.NET Core Detection service components for identifying details about client device, browser, engine, platform, and crawler.
In der startup.cs Datei muss man die Zeile einfügen, im Bereich ConfigureServices(..)
// Add detection services. services.AddDetectionCore() .AddDevice();
|
Dann muss man unter der Controller-Klasse nur noch die Using einbinden
using Wangkanai.Detection;
|
Und kann anschliessend direkt aus dem Request heraus den Client auswerten.
var client_Browser = Request.Browser(); var client_Device = Request.Device(); var client_Engine = Request.Engine(); var client_Platform = Request.Platform();
|
Hier ein Screenshot der Werte, welche man mit Wangkanai Detection ermitteln kann.
Auswertung zur Laufzeit
Laut Debugger
Name |
Value |
Type |
|
◢ |
client_Browser |
{Wangkanai.Detection.Browser} |
Wangkanai.Detection.Browser |
Bits |
0 |
byte |
|
Feature |
null |
Wangkanai.Detection.Feature |
|
Maker |
null |
string |
|
Name |
null |
string |
|
Type |
Generic |
Wangkanai.Detection.BrowserType |
|
Version |
null |
Wangkanai.Detection.IVersion |
|
◢ |
client_Device |
{Wangkanai.Detection.Device} |
Wangkanai.Detection.Device |
Crawler |
false |
bool |
|
Type |
Desktop |
Wangkanai.Detection.DeviceType |
|
◢ |
client_Engine |
{Wangkanai.Detection.Engine} |
Wangkanai.Detection.Engine |
Maker |
null |
string |
|
Name |
null |
string |
|
Type |
WebKit |
Wangkanai.Detection.EngineType |
|
Version |
null |
Wangkanai.Detection.IVersion |
|
◢ |
client_Platform |
{Wangkanai.Detection.Platform} |
Wangkanai.Detection.Platform |
Bits |
0 |
byte |
|
Name |
null |
string |
|
Type |
Windows |
Wangkanai.Detection.PlatformType |
|
Version |
null |
Wangkanai.Detection.IVersion |