Class DeviceDetector
- Namespace
- Dynamicweb.Frontend.Devices
- Assembly
- Dynamicweb.dll
Represents a device detector that is used to detect the device information from a request or context.
public class DeviceDetector
- Inheritance
-
DeviceDetector
- Inherited Members
Methods
DetectFromRequest(IContext)
Detects device information from the specified context by examining query parameters, session data, or the user agent string.
public static DeviceInfo DetectFromRequest(IContext context)
Parameters
context
IContextAn IContext representing the current HTTP context from which to detect device information.
Returns
- DeviceInfo
A DeviceInfo object containing the detected device information.
Remarks
The method determines the device information by first checking for a "devicetype" parameter in the query string and storing it in the session if found. If "devicetype" is not found in the session, it falls back to parsing the user agent string from the request. If the context, request, or session is invalid, it returns a default DeviceInfo object.
IsDeviceDetectionEnabled(IContext)
Checks if device detection is enabled in the given context.
public static bool IsDeviceDetectionEnabled(IContext context)
Parameters
context
IContextThe context object.
Returns
- bool
True if device detection is enabled, otherwise false.