使用asp.net和C#进行移动设备检测

时间:2012-05-10 10:03:37

标签: mobile detection

我必须检测移动浏览器,如果检测为移动浏览器,那么我必须在网页上显示一些内容。

我正在使用Request.Browser.IsMobileDevice,但它像手机一样无法用于iPhone。

2 个答案:

答案 0 :(得分:0)

我真的不知道这是否对您有所帮助,但几个月前我使用了driveInfo来检测USB设备

也许这可以用来检测你的iPhone 试着看看这里:http://msdn.microsoft.com/en-us/library/system.io.driveinfo.isready.aspx

对于活动你可以试试这个:

static ManagementEventWatcher w = null;

private static void USBHandler(){ 

WqlEventQuery q; 
ManagementScope scope = new ManagementScope("root\\CIMV2"); 
scope.Options.EnablePrivileges = true; 
  q = new WqlEventQuery(); 
  q.EventClassName = "__InstanceCreationEvent"; 
  q.WithinInterval = new TimeSpan(0, 0, 3); 
  q.Condition = "TargetInstance ISA 'Win32_USBControllerdevice'"; 
  w = new ManagementEventWatcher(scope, q); 
  w.EventArrived += USBInserted; 
  w.Start(); 
}
private static void USBInserted(object sender, EventArgs e){

System.Windows.MessageBox.Show("USB inserted");
}

答案 1 :(得分:0)

看看http://51degrees.mobi/您可以将他们的nuget软件包下载到您的项目中,它可以很好地检测移动设备

相关问题