目前我使用以下代码检测手机,平板电脑。但我需要将此代码限制为移动。如果提供解决方案,您的建议可以得到赞赏。
DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("Mobile")
{
ContextCondition = (context =>
{
var manager = (context.Cache[WurflManagerCacheKey] as IWURFLManager);
var cabablities = manager.GetDeviceForRequest(context.Request.UserAgent);
return cabablities.GetCapability("is_wireless_device") == "true";
//return cabablities.GetCapability("mobile_browser").Contains("Opera");
//return cabablities.UserAgent.Contains("Opera");
})
});
答案 0 :(得分:0)
我会使用is_wireless_device
和is_tablet
功能来隔离手机:
if (is_tablet == false && is_wireless_device == true) {
//Must be a mobile phone
}