0

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.

JoseCarlos
  • 58
  • 1
  • 9
  • Why would you want to change the behavior of your service based on the device that requests it? – ZippyV Mar 15 '12 at 09:36

1 Answers1

1

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();
Community
  • 1
  • 1
Paul Alexander
  • 31,970
  • 14
  • 96
  • 151
  • Hi. I try this but I'm not getting the info. The mobile have a specific app. The service is not consuming by a browser. Instead is consumed by the app. – JoseCarlos Mar 14 '12 at 23:31
  • 1
    If you're making an HTTP request to the MVC service, there is a UserAgent value being sent - that's just part of the protocol. If you need to know exactly what it is, then log the user agent somewhere on your service and then you look at it to see what your app is sending. – Paul Alexander Mar 14 '12 at 23:36