一些网络应用程序会显示登录历史记录,它们可以告诉我我登录过,例如使用 Android,设备类型为“Samsung GT-I9505”。
我一直在查看 MVC 中的 httprequest 对象,但似乎找不到这些属性。我如何知道我的用户使用哪些设备/平台?
谢谢!
最佳答案
您可以使用HttpContext.Current.Request.UserAgent
例如:
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
}
用户代理列表:http://www.webapps-online.com/online-tools/user-agent-strings或 http://www.zytrax.com/tech/web/mobile_ids.html
对于 GT-I9505:http://www.webapps-online.com/online-tools/user-agent-strings/dv/brand125521/samsung-galaxy-s4
关于asp.net-mvc - 在 ASP.NET MVC5 中,如何获取移动用户请求的平台和设备类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28517149/