Access Device Capabilities

You can identify the capabilities of a mobile device like any other browser’s capabilities. In fact, you use the exact same class for this purpose (HttpBrowserCapabilities). You should cast this class into a MobileCapabilities class, and query the result, as the following syntax:

((MobileCapabilities)Request.Browser).HasCapability(“GPSEnabled”, null);

Notice that the HasCapability method takes two arguments, capabilityName, which is a named stored in a dictionary, and optionalArgument, which may help the evaluation process.

You can also create your own custom capabilities. You should use the following syntax:

public static bool IsGPSEnabled (MobileCapabilities capabilities, string optArg)
    //Your code here.

Be aware of that your method must return a Boolean value, and take two arguments, a strongly typed MobileCapabilities and a string. After defining your method, you must include the following markup in your web.config:

    <filter name=”GPSEnabled” type=”Namespace.ClassName, AssemblyName” method=”IsGPSEnabled” />

Then you can query your device’s capabilities with the topmost code. MobileCapabilities class exposes the same strongly typed properties as the Request.Browser class. However, there is another way to enquire browser capabilities. You can also use the following syntax:


These enquires always require string or null values, so watch out to cast them into proper format.

Further Readings
Mobile Device Capabilities

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s