Now, I wanted to do a check for tablet devices and redirect to desktop version of site if it is a tablet device. As of now it is done in the above code but only for iPad.
I need to add conditions for the following tablet devices and all others too that are not listed. Can anyone help me?
You could use the Request.Browser.ScreenPixelsWidth to determine if it meets a certain size applicable to view the desktop version. Recommend you check what sort of sizes they use.
Member
1 Points
11 Posts
Detect Mobile and Tablet devices
Feb 09, 2012 06:09 PM|satajl|LINK
Hi Friends...Can anyone of you help me in my below query....
In my web application I use the following code to detect any mobile devices and redirect to the mobile version of site.
string strUserAgent = Request.UserAgent.ToString().ToLower();
if (strUserAgent != null)
{
if ((Request.Browser.IsMobileDevice == true ||
strUserAgent.Contains("iphone") || strUserAgent.Contains("ipod") ||
strUserAgent.Contains("symbian") || strUserAgent.Contains("android") ||
strUserAgent.Contains("windows ce") || strUserAgent.Contains("blackberry") ||
strUserAgent.Contains("palm") || (strUserAgent.Contains("mobile") && !strUserAgent.Contains("ipad")) ||
strUserAgent.Contains("opera mini")) && (Session["VFS"] == null))
{
string fullsiteurl = Request.RawUrl.ToString();
Response.Redirect("http://m.huggies.com");
}
}
Now, I wanted to do a check for tablet devices and redirect to desktop version of site if it is a tablet device. As of now it is done in the above code but only for iPad.
I need to add conditions for the following tablet devices and all others too that are not listed. Can anyone help me?
Samsung Galaxy Tab 10.1 GT-P7510
Mozilla/5.0 (Linux; U; Android 3.1; xx-xx; GT-P7510 Build/HMJ37) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13
Samsung Galaxy Tab GT-P1000
Mozilla/5.0 (Linux; U; Android 2.2; es-es; GT-P1000 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
Samsung Galaxy Tab SC-01C for DoCoMo
Mozilla/5.0 (Linux; U; Android 2.2; ko-kr; SC-01C Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
Samsung Galaxy Tab SCH-I800
Mozilla/5.0 (Linux; U; Android 2.2; en-us; SCH-I800 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
Samsung Galaxy Tab SGH-T849
Mozilla/5.0 (Linux; U; Android 2.2; en-us; SGH-T849 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
Samsung Galaxy Tab SHW-M180L
Mozilla/5.0 (Linux; U; Android 2.2; xx-xx; SHW-M180L Build/FROYO) AppleWebKit/525.10 (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2
Samsung Galaxy Tab SHW-M180S
Mozilla/5.0 (Linux; U; Android 2.2; xx-xx; SHW-M180S Build/FROYO) AppleWebKit/525.10 (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2
Samsung Galaxy Tab SPH-P100
Mozilla/5.0 (Linux; U; Android 2.2; 0-; SPH-P100 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
Participant
1014 Points
830 Posts
Re: Detect Mobile and Tablet devices
Feb 10, 2012 06:40 AM|breath2k|LINK
You could use the Request.Browser.ScreenPixelsWidth to determine if it meets a certain size applicable to view the desktop version. Recommend you check what sort of sizes they use.
Star
14065 Points
3270 Posts
Re: Detect Mobile and Tablet devices
Feb 14, 2012 08:30 AM|roopeshreddy|LINK
Hi,
Check the below link!
http://detectmobilebrowsers.com/
Hope it helps u...
Roopesh Reddy C
Roopesh's Space
Member
1 Points
11 Posts
Re: Detect Mobile and Tablet devices
Dec 07, 2012 04:22 PM|satajl|LINK
Thanks guys for the replies. I hardcoded for the lists that I had mentioned.
@Roopesh Reddy. I tested using the solution that you have given and it works like a charm :)