asp.net获取客户端浏览器信息不准

2024-12-17 09:05:20
推荐回答(1个)
回答1:

protected BowserType UserBowserType
    {
        get
        {
            string b = Request.Browser.Browser;
            b = string.IsNullOrEmpty(b) ? "other" : b;
            switch (b.ToUpper())
            {
                case "IE": return BowserType.IE;
                case "FIREFOX": return BowserType.FIREFOX;
                case "APPLEMAC-SAFARI": if (Request.UserAgent.IndexOf("Chrome") > 0)
                        return BowserType.CHROME;
                    else
                        return BowserType.OTHER;
                default: return BowserType.OTHER;
            }
        }
    }