zoukankan      html  css  js  c++  java
  • asp.net获取浏览器端操作系统名称

    /// <summary>
    /// 获取浏览器端操作系统名称
    /// </summary>
    /// <returns></returns>
    public static string GetOSName()
    {
        string osVersion = System.Web.HttpContext.Current.Request.Browser.Platform;
        string userAgent = System.Web.HttpContext.Current.Request.UserAgent;

        if (userAgent.Contains("NT 6.2"))
        {
            osVersion = "Windows8/Server 2012";
        }
        if (userAgent.Contains("NT 6.1"))
        {
            osVersion = "Windows7/Server 2008 R2";
        }
        else if (userAgent.Contains("NT 6.0"))
        {
            osVersion = "Windows Vista/Server 2008";
        }
        else if (userAgent.Contains("NT 5.2"))
        {
            osVersion = "Windows Server 2003";
        }
        else if (userAgent.Contains("NT 5.1"))
        {
            osVersion = "WindowsXP";
        }
        else if (userAgent.Contains("NT 5"))
        {
            osVersion = "Windows2000";
        }
        else if (userAgent.Contains("NT 4"))
        {
            osVersion = "WindowsNT4.0";
        }
        else if (userAgent.Contains("Me"))
        {
            osVersion = "WindowsMe";
        }
        else if (userAgent.Contains("98"))
        {
            osVersion = "Windows98";
        }
        else if (userAgent.Contains("95"))
        {
            osVersion = "Windows95";
        }
        else if (userAgent.Contains("Mac"))
        {
            osVersion = "Mac";
        }
        else if (userAgent.Contains("Unix"))
        {
            osVersion = "UNIX";
        }
        else if (userAgent.Contains("Linux"))
        {
            osVersion = "Linux";
        }
        else if (userAgent.Contains("SunOS"))
        {
            osVersion = "SunOS";
        }
        return osVersion;
    }

  • 相关阅读:
    查询避免Unknown column ‘xxx’ in ‘where clause’
    mybatis判断集合长度
    springbootjpa的dao层也会出现找不到javabean的操作
    Kotlin小测试
    java8特性表达式
    layui的入门使用
    tomcat去除项目访问路径限制
    XShell上传文件到Linux服务器上
    git添加新工程
    天气预报
  • 原文地址:https://www.cnblogs.com/ilookbo/p/4063765.html
Copyright © 2011-2022 走看看