简体   繁体   English

从MVC REST服务发现设备类型

[英]Discovering device type from MVC REST service

I have a web application written in ASP.NET MVC 3 . 我有一个用ASP.NET MVC 3编写Web应用程序 This application have a pair of controller with some mvc action method that return json . 此应用程序具有一对带有某些mvc action方法的控制器,这些方法返回json These methods are intended to be consumed by a mobile application (BlackBerry and IPhone apps). 这些方法旨在由移动应用程序 (BlackBerry和IPhone应用程序)使用。

My question is: How can I discover which device are consuming these service? 我的问题是:我如何发现哪个设备正在使用这些服务? Sample: The action method XXX is being calling by a Iphone 4S. 示例:Iphone 4S正在调用操作方法XXX。 The action method YYY is being calling by a BlackBerry Torch. BlackBerry Torch正在调用操作方法YYY。

Devices don't expose their exact identity to the server when requesting data, however the UserAgent can be used to make a good guess. 设备在请求数据时不会向服务器公开其确切身份,但是可以使用UserAgent进行猜测。

For example What is the iPhone 4 user-agent? 例如, 什么是iPhone 4用户代理?

if( Request.UserAgent.Contains( "iPhone OS" ) )
  DoSomeIPhoneyThing();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM