Device macros

CurrentDevice

The CurrentDevice object holds information about the device detected for the current visitor. The system identifies devices based on their user-agent and retrieves the data about the capabilities of devices using the HttpBrowserCapabilities class of the .NET Framework.

51Degrees device detection

The default device recognition of the .NET Framework might not be sufficiently accurate for your needs. If you want to implement device profiles effectively, we recommend utilizing the 51Degrees device detection.

You can take advantage of the CurrentDevice object when defining conditions for device profiles and in general macro expressions. To view a full list of the device properties that are available by default, see the HttpBrowserCapabilities Properties article on the Microsoft Developer Network.

The properties are accessible through the Data container and indexing. For example:

  • {% CurrentDevice.Data[“JavaScript”] %}
  • {% CurrentDevice.Data[“IsMobileDevice”] %}

CurrentDeviceProfile

To get information about the device profile assigned to the current visitor’s device, use the CurrentDeviceProfile object in macros:

  • You can access the device profile’s system data through its properties, for example: {% CurrentDeviceProfile.ProfilePreviewWidth %}
  • To directly get the device profile’s name, use the following expression: {% CurrentDeviceProfileName %}