I have samsung galaxy s2, in C# code it shows Request.Browser.IsMobileDevice = false, but I want to use mobile version for my application. How to have ability to show mobile version of my website, for Android devices?
Thank you, so much.
Sergey.
You can check the User-Agent
HTTP header.
The user-agent is an identifier that (usually) contains the browser name and version, as well as the name and version of the platform or OS the browser is running on. The current standard is to have this split into space-separated elements, but in reality the User-Agent
field can be set to anything.
Example:
Mozilla/5.0 Windows NT 6.1 WOW64 rv 8.0 Gecko/20100101 Firefox/8.0
This shows that I'm running Firefox 8.0 (which uses Mozilla renderer v5.0 and Gecko layout engine release 2010/01/01) on a 64-bit version of Windows NT 6.1 Release (which is Windows 7).
You can get more info about user agent strings from here: http://www.useragentstring.com/
Use 51Degrees.mobi from NuGet for a one click install with zero configuration which will correct this issue.
You can create a file in App_Browsers with a regex to identify the browser, the following one is to firefox in Android:
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With