How to detect mobile phone name/model no from asp.net? RRS feed

  • Question

  • User660571870 posted

    Hi experts,

    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.


    Wednesday, July 28, 2010 4:41 AM


All replies

  • User-25924017 posted

    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 curcontext = HttpContext.Current;
            string user_agent = curcontext.Request.ServerVariables["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 |wap-|wapa|wapi|wapp|datalogic scorpio|wapr|webc|winw|winw|xda|xda-|";

     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.

    Wednesday, July 28, 2010 5:41 AM
  • User660571870 posted

    Thanks for your reply .I will try it and update the feedback.

    Wednesday, July 28, 2010 10:35 AM
  • User1943143334 posted


    Check this link,



    Hope it helps u... 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 28, 2010 12:56 PM
  • User981004358 posted

    MDBF has a Final release announcement<o:p></o:p>

    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.<o:p></o:p>


    51degrees.mobi Foundation the .NET open source API is now in Codeplex http://51degrees.codeplex.com/<o:p></o:p>

    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.<o:p></o:p>


    Friday, August 13, 2010 9:55 AM