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;
    }

  • 相关阅读:
    Python基础之内存管理与垃圾回收机制
    Git常用命令
    Git分支操作
    码云配置SSH公钥
    Git基本操作
    Git基本理论
    版本控制
    Python基础之Python语法
    成为一名JAVA高级工程师你需要学什么【转】
    一个java高级工程师的进阶之路【转】
  • 原文地址:https://www.cnblogs.com/ilookbo/p/4063765.html
Copyright © 2011-2022 走看看