JoseCarlos
JoseCarlos

Reputation: 58

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.

Upvotes: 0

Views: 334

Answers (1)

Paul Alexander
Paul Alexander

Reputation: 32367

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();

Upvotes: 1

Related Questions