【发布时间】:2014-08-18 08:16:28
【问题描述】:
我在 MVC 上的 .NET 中使用 51 度,我只是注意到 51 度将平板电脑默认重定向为 IsMobile。
我只想重定向移动流量,即手机等而不是平板电脑。平板电脑应该使用我的默认“桌面”布局。
我是否可以使用(Lite)51 度仅重定向移动流量而不是平板电脑流量?
【问题讨论】:
标签: asp.net-mvc mobile tablet 51degrees
我在 MVC 上的 .NET 中使用 51 度,我只是注意到 51 度将平板电脑默认重定向为 IsMobile。
我只想重定向移动流量,即手机等而不是平板电脑。平板电脑应该使用我的默认“桌面”布局。
我是否可以使用(Lite)51 度仅重定向移动流量而不是平板电脑流量?
【问题讨论】:
标签: asp.net-mvc mobile tablet 51degrees
我对他们的正常重定向配置一无所知,但您可以在服务器端轻松处理。 51Degrees 将“IsTablet”和“IsSmartPhone”属性添加到 request.Browser。你可以在适当的时候这样做:
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
【讨论】:
这有点晚了,但我是 51Degrees 的工程师之一。我们现在提供免费的基本云服务,可以访问“IsTablet”属性。然后可以使用它来定制您的重定向选项。
调用此选项的基本示例如下所示:
https://cloud.51degrees.com/api/v1/*LICENCE_KEY*/match?user-agent=iphone&Values=IsTablet
【讨论】: