我如何可以检测从我的网站被访问的设备? [英] How can I detect the device from which my website is accessed?

查看:119
本文介绍了我如何可以检测从我的网站被访问的设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有.NET网站,主要是建立对于桌面浏览器,但我目前正在它的移动版本。我正在试图做的是根据其所被用户访问的设备下载该网站。有没有一种方法,我可以获取用户的设备信息,当他们要求的网站?

I have .NET website that is mainly built for desktop browsers but I'm currently making a mobile version of it. What I'm trying to do is load the website according to the device on which it is accessed by the user. Is there a way that I can get information about the user's device when they request the site?

问候,
萨米特。

Regards, Sumit.

推荐答案

正如其他人则建议您可以使用 System.Web.HttpBrowserCapabilities 访问类通过的Request.Browser 浏览器定义文件但是> 的信息是完全没有价值的。

As suggested by others you can use the System.Web.HttpBrowserCapabilities class accessible through Request.Browser however without updated browser definition files the information is completely worthless.

例如,如果你使用 Request.Browser.IsMobileDevice 此的的给你你想要的,而是基于一组非常在Windows .NET框架的文件夹定期约会前pressions。

For example, if you use Request.Browser.IsMobileDevice this should give you what you want, but is based on a set of very dated regular expressions in your .NET framework folders in Windows.

您可以看到的那种可以在(目前未与被爱)中遇到的问题发布<一个href=\"http://stackoverflow.com/questions/8166763/why-am-i-getting-these-strange-results-when-looking-at-browser-capabilities\">here对堆栈溢出。

You can see the kind of problems that can be encountered on a (currently unanswered and unloved) post here on Stack Overflow.

如果你不保持浏览器定义文件更新(这是不小的任务),然后计划很简单,不走这路线

如果你只是想知道用户是否观看移动设备上,然后这里有几个选择:

If you simply want to know whether the user is viewing on a mobile device then here are a few options:

  • Detect Mobile Browsers
  • 51Degrees.mobi
  • WURFL
  • User Agent Info

他们有些是免费的,有些不是,如果你真的只有在它是一个移动设备感兴趣的话,我的建议是使用检测手机浏览器。

Some of those are free, some aren't and if you are really only interested in whether it is a mobile device, my recommendation would be to use Detect Mobile Browsers.

这篇关于我如何可以检测从我的网站被访问的设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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