Last post Aug 13, 2010 09:55 AM by amar_j
Jul 28, 2010 04:41 AM|sobinscott|LINK
Can I detect the Name/model no of the mobile phones ,which are browsing my asp.net website from C# code behind? I need to show welcome message, addressing their model numbers and redirect to appropriate pages.
Thanks in advance for your reply.
Jul 28, 2010 05:41 AM|SSA|LINK
I don't think thats possible directly from asp.net that abstract.
When a mobile browser sends a request to asp.net, only relevant thing you can have in this context is: HTTP_USER_AGENT
HttpContext currentcontext = HttpContext.Current;
string user_agent = currentcontext.Request.ServerVariables["HTTP_USER_AGENT"];
Most of the mobile browsers they send, extra details (may be phone name and model but it depends on agent) in this string (and not all browsers* will send this, as they might be using Windows CE agent, or FireFox or Chrome, which is not meaningful for mobile/handheld
device name and model), there you can have a search for phone names (if they exists in user agent sent by browser) like
Note: I am referencing below code, from an article on internet but I don't remember that anymore.
// Checks if the 4 first chars of the user-agent match any of the most popular user-agents (this list may be missing some names as its growing)
string popularUserAgent = "|acs-|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv|palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|w3c
if (popularUserAgent .Contains("|" + user_agent.Substring(0, 4) + "|"))
//Add you logic here
//Can not detect device.
You can enhance above logic for a showing full name of popular phones but be aware that they may or may not be there in HTTP_USER_AGENT.
Jul 28, 2010 10:35 AM|sobinscott|LINK
Thanks for your reply .I will try it and update the feedback.
Jul 28, 2010 12:56 PM|roopeshreddy|LINK
Check this link,
Hope it helps u...
Aug 13, 2010 09:55 AM|amar_j|LINK
MDBF has a Final release announcement
Due to the organizational restructuring of the team that developed and supported the Mobile Device Browser file, we will no longer have the resources to support and update this CodePlex project. The team
will be providing two more releases – one on the 27th July 2010 and the final release on the 24th August 2010.
51degrees.mobi Foundation the .NET open source API is now in Codeplex
It easily detects if the request is coming from any mobile device and redirects user to mobile landing page. It has some user friendly samples to try out.