Reputation: 951
Some webapps show a sign-in history, and they can tell that I signed in for example using Android, and with device type 'Samsung GT-I9505'.
I've been looking into the httprequest object in MVC but I cannot seem to find these properties. How can I tell which devices/platforms my users use?
Thanks!
Upvotes: 1
Views: 1754
Reputation: 1444
You can use HttpContext.Current.Request.UserAgent
For example :
string ua = HttpContext.Current.Request.UserAgent.ToLower();
if (ua.Contains("iphone"))
{
// iPhone
}
else if (ua.Contains("ipad"))
{
// iPad
}
else if (ua.Contains("GT-I9505"))
{
// your case
}
User-agent list : http://www.webapps-online.com/online-tools/user-agent-strings or http://www.zytrax.com/tech/web/mobile_ids.html
For GT-I9505 : http://www.webapps-online.com/online-tools/user-agent-strings/dv/brand125521/samsung-galaxy-s4
Upvotes: 1