Question: I am trying to find out if a user viewing my site is a mobile user. I have used "HttpContext.Current.Request.Browser.IsMobileDevice " and found it pretty useless as it didn't not pick up on my usage when viewing the site on my phone.

Is there another way to find out if the user is a mobile user that works better?

I have looked at user agent and that just looks messy!

I should point out that this has nothing to do with CSS, I want to log if the user is a mobile user in a database table. 

And yes, I know google analytics can do this already but unfortunately its not my decision!

Thanks

Answer: 
Try to test with this code....

```
    string sUA = Request.UserAgent.Trim().ToLower();

    uaString.InnerText = Request.UserAgent;

    if (sUA.Contains("ipod") || sUA.Contains("iphone"))
        isMobile = true;

    if (sUA.Contains("android"))
        isMobile = true;

    if (sUA.Contains("opera mobi"))
        isMobile = true;

    if (sUA.Contains("windows phone os") && sUA.Contains("iemobile"))
        isMobile = true;

    if (sUA.Contains("fennec"))
        isMobile = true;

```
Check out 

[51degrees](http://51degrees.codeplex.com/)

> 
> It’s provided as a .NET open source class library that detects mobile
>  devices and browsers, enhancing the information available to .NET
>  programmers. Using 51Degrees.mobi Device Data, accurate screen sizes,
>  input methods, plus manufacturer and model information are all
>  available. Mobile handsets can optionally be redirected to content
>  designed for mobile devices. Smart phones, tablets and feature phones
>  are all supported.
> 
> 
> 

As pointed out in the comments.

> 
> The detection and redirection part of the product offering is free.
>  The free trial is for their mobile optimzation products
> 
> 
>