how do I detect user operating system

前端 未结 11 929
难免孤独
难免孤独 2020-12-01 03:58

I have the following code to obtain user details:

HttpBrowserCapabilities bc = HttpContext.Current.Request.Browser;
string UserAgent = HttpContext.Current.Re         


        
11条回答
  •  执念已碎
    2020-12-01 04:14

    Use Request.UserAgent

    if (Request.UserAgent.IndexOf("Windows NT 5.1") > 0)
    {
    //xp
    }
    else if (Request.UserAgent.IndexOf("Windows NT 6.0") > 0)
    {
    //VISTA
    }
    else if (Request.UserAgent.IndexOf("Windows NT 6.1") > 0)
    {
    //7
    }
    else if (Request.UserAgent.IndexOf("Windows NT 6.2") > 0) 
    { 
    //8
    }
    else if (Request.UserAgent.IndexOf("Windows NT 6.3") > 0) 
    { 
    //8.1
    }
    else if (Request.UserAgent.IndexOf("Windows NT 10.0") > 0) 
    { 
    //10
    }
    

提交回复
热议问题