ASP.NET Browser Definition File for Android (android.browser)



Automate your network audit and documentation

When trying to use the Request.Browser.IsMobileDevice property in ASP.NET you may be disappointed to see it return false even when using a mobile device such as an iPhone. This is because ASP.NET relies on browser definition files (with an extension of .Browser) such as iPhone.browser to detect the capabilities of a remote browser.

Though there are a number of more advanced solutions than Browser definition files they are still useful in simple situations.

Codeplex has an update of the browser definition files that came with ASP.NET 4 however these do not include a browser definition file for Android devices.
http://aspnet.codeplex.com/releases/view/41420


The following should provide some help - just save to the App_Browsers directory as Android.browser.

The following is the output from some ASP.NET sample code

Is Mobile Device: True
Browser: Android
Browser: ID android
Browser: Version 4.0.4



<browsers>
  <!--Mozilla/5.0 (Linux; U; Android 4.0.4; en-us; sdk Build/MR1) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30-->
  <browser id="Android" parentID="safari1plus">
    <identification>
      <userAgent match="Android.(?'version'(?'major'\d+)(?'minor'\.\d+)(?'build'\.\d+))\w*" />
    </identification>
    <capabilities>
      <capability name="browser"                        value="Android" />
      <capability name="majorVersion"                   value="${major}" />
      <capability name="minorVersion"                   value="${minor}" />
      <capability name="version"                        value="${version}" />
      <capability name="type"           value="Android${major}" />
      <capability name="platform" value="Android" />
      <capability name="mobileDeviceManufacturer"       value="Google" />
      <capability name="activeXControls"                value="false" />
      <capability name="backgroundSounds"               value="false" />
      <capability name="beta"                           value="false" />
      <capability name="canSendMail"                    value="false" />
      <capability name="cookies"                        value="true" />
      <capability name="frames"                         value="false" />
      <capability name="isColor"                        value="true" />
      <capability name="isMobileDevice"                 value="true" />
    </capabilities>
  </browser>
</browsers>

Comments

Popular posts from this blog

Windows Server 2016, 2019, 2022, Windows 10 and Windows 11: Date and time "Some settings are managed by your organization".

TFTPD32 or TFTPD64 reports Bind error 10013 An attempt was made to access a socket in a way forbidden by its access permissions.

Enable function lock for F1-F12 on HP ZBook mobile workstations