4

Why .Net HttpContext.Current.Request.Browser.IsMobileDevice is false in Firefox 44.* on Android Device?

And how I do to fix this in my .Net Application? I try create an broser definition in App_Browsers, but doesn't work!

User agent is: Browser: Firefox, Version: 44.0, UserAgent: Mozilla/5.0 (Android 5.0; Mobile; rv:44.0) Gecko/44.0 Firefox/44.0

*Sorry about bad english

Maykol Rypka
  • 531
  • 6
  • 19

2 Answers2

4

Another developer in my company solved that problem, he just make a new file in App_Browsers "firefoxnew.browser" folder with this content:

<browsers>
    <!--Mozilla/5.0 (Android 5.0; Mobile; rv:44.0) Gecko/44.0 Firefox/44.0-->
    <browser id="FirefoxMobile" parentID="firefox3plus">
        <identification>
            <userAgent match="Mozilla.+\(Android.+Mobile.*\)" />
        </identification>
        <capabilities>
            <capability name="isMobileDevice" value="true" />
        </capabilities>
    </browser>
</browsers>
Maykol Rypka
  • 531
  • 6
  • 19
2

I had a similar problem with older .Net versions - I found that certain 'phablet' device were slipping through so I read into the UserAgent string

httpContext.Request.UserAgent != null 
  && (httpContext.Request.UserAgent.ToLowerInvariant().Contains("mobi")
  || httpContext.Request.UserAgent.ToLowerInvariant().Contains("ereader")
  || httpContext.Request.UserAgent.ToLowerInvariant().Contains("smartphone")
  || httpContext.Request.UserAgent.ToLowerInvariant().Contains("iphone")
  || httpContext.Request.UserAgent.ToLowerInvariant().Contains("ipad")
  || httpContext.Request.UserAgent.ToLowerInvariant().Contains("ios")
  || httpContext.Request.UserAgent.ToLowerInvariant().Contains("android")

of course this is if you need server-side device detection, if doing this client-side you would want to look in the navigator.userAgent object...

rwcorbett
  • 473
  • 5
  • 12
  • possible duplicate of http://stackoverflow.com/questions/8340644/request-browser-ismobiledevice-false-for-android-why – rwcorbett Mar 16 '16 at 02:38