如何IsMobileDevice工作? [英] How does IsMobileDevice work?

查看:195
本文介绍了如何IsMobileDevice工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MSDN 使得它听起来那么容易检测手机浏览器:

MSDN makes it sound so easy to detect a mobile browser:

if (Request.Browser["IsMobileDevice"] == "true" ) 
{
    Response.Redirect("MobileDefault.aspx");
}

其实,它看起来像你也可以只检查Request.Browser.IsMobileDevice。但这是如何实际工作?我甚至不具有一个.browser文件......这是怎么回事这里的幕后?是否有ASP.NET 2.0的一些内置的默认设置?

Actually, it looks like you can also just check Request.Browser.IsMobileDevice. But how does this actually work? I don't even have a .browser file... what's going on behind the scenes here? Are there some built-in defaults for ASP.NET 2.0?

推荐答案

若干* .browser文件是随.NET:

A number of *.browser files are shipped with .NET:

C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\Browsers

运行时使用常规的前pressions从* .browser文件来匹配输入的用户代理字符串,然后设置了一堆根据每个找到匹配的属性(可以有层次结构中的几个)

The runtime uses regular expressions from the *.browser files to match against the incoming User-Agent string, and then sets a bunch of properties based on each match it finds (there can be several in the hierarchy).

如果你需要深入的移动设备支持,考虑安装MDBF,这增加了支持约400设备:

If you need in-depth mobile device support, consider installing the MDBF, which adds support for about 400 devices:

HTTP://mdbf.$c$cplex.com/

这篇关于如何IsMobileDevice工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆