I want to detect if a mobile device is an Tablet (iPad) or not in ASP.net I had a look at 51degrees project but the function to detect a tablet isn't available in the free version - and since we distribute our ASP.net solution to 100's of customers, we cannot buy a 51degrees license for all of them.
Are there any free or open source alternatives for 51degrees available? Or will newer versions of MVC (4?) provide more information in detail than the plain IsMobileDevice()?
Thanks, Konrad
You can request the user agent and check to see if it contains 'ipad' like so
bool isIpad = Request.UserAgent.ToLower().Contains("ipad");
You don't need to "detect an iPad". Just use Media Queries to give you support for the iPad as the Safari browser that comes with iPad already understands CSS3:
CSS3 Media Queries
/* iPads (landscape) */
@media screen and (min-device-width : 768px)
and (max-device-width : 1024px) and (orientation : landscape) {
...
}
/* iPads (portrait) */
@media screen and (min-device-width : 768px) and (max-device-width : 1024px)
and (orientation : portrait) {
...
}
Your best bet is to use HTML5Boilerplate as it fixes some other things for iPad also. Use Modernizr for feature detection; it comes with HTML5Boilerplate.
HTML5 Boilerplate
20 Snippets You should be using from Html5 Boilerplate
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