i-Phone,i-Pad Browser Detection of ASP.NET Mobile Website


ASP.NET Mobile Website has support for Mobile Browser detecting User-Agents in Mobile Database (WURFL) or mobile.browser(mobiplex).

i-Pad’s User -Agent Strings are as :

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/7B334b Safari/531.21.10

i-Phone’s User-Agent Strings are as:

HTTP_USER_AGENT=Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1C25 Safari/419.3

Lets Write some JavaScript Code to redirect the asp.net mobile website to i-Phone/i-Pad specific Website.

write in asp.net_website/mobile/default.aspx:

<scripttype=”text/javascript”>


if ((navigator.userAgent.match(/iPhone/i)) ||

(navigator.userAgent.match(/iPod/i))) {

if (document.cookie.indexOf(“iphone_redirect=false”) == -1) window.location = http://localhost:8922/EMREC/Mobile/i-Phone/Default.aspx/&#8221;;

}

</script>

Next check the mobile website in Windows Phone & i-Phone View & the redirection view from http://website.com/mobile to http://website.com/mobile/i-Phone.

This slideshow requires JavaScript.

Advertisements

About Anindita
Anindita Basak is working as Big Data Cloud Consultant in Microsoft. Worked in multiple MNCs as Developer & Senior Developer on Microsoft Azure, Data Platform, IoT & BI , Data Visualization, Data warehousing & ETL & of course in Hadoop platform.She played both as FTE & v- employee in Azure platform teams of Microsoft.Passionate about .NET , Java, Python & Data Science. She is also an active Big Data & Cloud Trainer & would love share her experience in IT Training Industry. She is an author, forum contributor, blogger & technical reviewer of various books on Big Data Hadoop, HDInsight, IoT & Data Science, SQL Server PDW & PowerBI.

One Response to i-Phone,i-Pad Browser Detection of ASP.NET Mobile Website

  1. Pingback: Accommodation for the holidays

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: