简体   繁体   中英

Discovering device type from MVC REST service

I have a web application written in ASP.NET MVC 3 . This application have a pair of controller with some mvc action method that return json . These methods are intended to be consumed by a mobile application (BlackBerry and IPhone apps).

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. The action method YYY is being calling by a BlackBerry Torch.

Devices don't expose their exact identity to the server when requesting data, however the UserAgent can be used to make a good guess.

For example What is the iPhone 4 user-agent?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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