0

I want to detect default browser of android inside my MVC controller. I have mobile detection right now:

public ActionResult Index()
{
    if (WurflHelper.Instance.IsMobile(Request.UserAgent))
    {
        return View("MobileView");
    }
    else
    {
        return View();
    }
}

How can i detect android default browser (not chrome). I need UserAgent parameters matches for this detection. Thanks for advice.

--------------EDIT--------------------------------------------------------------

i found this solution for client (javascript) : How to detect the stock Android browser. I need same solution for asp.net MVC

Community
  • 1
  • 1
freethinker
  • 2,257
  • 4
  • 26
  • 49
  • Hi. What the regex? :) – freethinker May 05 '15 at 09:56
  • Regex based solutions don't accurately detect different device types. Android is also used in Netbook devices, TVs and set top boxes. 51Degrees (my company) provide a NuGet package that enhances the Request.Browser.IsMobile values returned by the default .NET deployment to be more accurate and address this problem. You'd use Request.Browser.IsMobileDevice to determine if the request is from a mobile. Other properties for browser name and version are also updated. The packages are available at https://51degrees.com/support/documentation/net/distributions – James Rosewell May 06 '15 at 08:58

2 Answers2

2

I noticed that you are already using WURFL to detect the device. You could simply use the mobile_browser or advertised_mobile_browser capability to determine the browser of the device.

Elliot Fehr
  • 764
  • 6
  • 10
0

You can use this Request.Browser to get the browser info. Below is an example

var moo = Request.Browser;
var Name =  moo.Browser;
var Version =  moo.Version; 
var Major_Version = moo.MajorVersion;
var Minor_Version =  moo.MinorVersion;
शेखर
  • 17,412
  • 13
  • 61
  • 117