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:
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.
Mobile Device Capabilities