Redirect only Mobile devices with 51 Degrees

899 Views Asked by At

I'm using 51 Degrees in .NET on MVC and it's only just come to my attention that 51 degrees redirects Tablets as default with what it classes as IsMobile.

I only want to redirect mobile traffic, ie phones etc and not tablets. Tablets should be using my default "Desktop" layout.

Is there anyway I can use the (Lite) 51 Degrees to only redirect mobile traffic and not tablet traffic?

2

There are 2 best solutions below

0
On

A bit late to this but i'm one of the engineers over at 51Degrees. We now offer a free basic Cloud service that gives access to the "IsTablet" property. This can then be used to tailor your re-direct options.

A basic example of calling against this option would look like:

https://cloud.51degrees.com/api/v1/*LICENCE_KEY*/match?user-agent=iphone&Values=IsTablet
1
On

I don't know anything about their normal redirect configuration, but you can handle this easily on the server side. 51Degrees adds the "IsTablet" and "IsSmartPhone" properties to request.Browser. You could do this where appropriate:

var request = HttpContext.Current.Request; //or wherever you're getting it from
bool smartPhoneFlag, tabletFlag;
bool.TryParse(request.Browser["IsTablet"])
bool.TryParse(request.Browser["IsSmartPhone"])

if(smartPhoneFlag && !tabletFlag)
{
    //redirect
}
//else continue on