Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request.Browser.Platform not returning iPad, OSX, or Windows7

I'm working on some advanced browser detection, and I've downloaded the MDBF browser file from CodePlex.

Unfortunately my Request.Browser.Platform, along with a few other things is returning "Unknown" on both my iPad Mac OSX (Snow Leopard) and on Windows7

Does anyone know of a good advanced .browser file out there that does the same thing for non mobile devices as the MDBF does for mobile devices?

like image 863
Chase Florell Avatar asked Jun 06 '10 19:06

Chase Florell


2 Answers

I've solved my particular issue (detecting iPad) with the following file in my application's App_Browsers folder:

<browsers>
  <!-- Mozilla/5.0 (iPad; U; CPU OS 4_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C134 Safari/6533.18.5 -->
  <gateway id="IPad" parentID="Safari">
    <identification>
      <userAgent match="iPad" />
    </identification>

    <capabilities>
      <capability name="mobileDeviceModel"               value="IPad" />
      <capability name="mobileDeviceManufacturer"        value="Apple" />
      <capability name="isMobileDevice"                  value="true" />
    </capabilities>
  </gateway>
</browsers>

Then in the code I test:

if (Request.Browser.MobileDeviceModel == "IPad")
  ...
like image 183
Anthony Serdyukov Avatar answered Nov 20 '22 14:11

Anthony Serdyukov


Use Request.UserAgent instead.

Beware that it includes the word Mobile as well:

  Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us)
  AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 
  Mobile/7B367 Safari/531.21.10

From Apple on preparing content for iPad:
https://developer.apple.com/library/content/technotes/tn2010/tn2262/_index.html

like image 42
Leah Avatar answered Nov 20 '22 13:11

Leah