• 网页跳H5实例


            public static void CheckAgent()
            {
                string redirect = string.Empty;
                string agent = HttpContext.Current.Request.UserAgent;
                string path = HttpContext.Current.Request.Url.AbsolutePath;
                string[] keywords = { "Android", "iPhone", "iPod", "iPad", "Windows Phone", "MQQBrowser" };
                //排除 Windows 桌面系统 
                if (!agent.Contains("Windows NT") || (agent.Contains("Windows NT") && agent.Contains("compatible; MSIE 9.0;")))
                {
                    //排除 苹果桌面系统 
                    if (!agent.Contains("Windows NT") && !agent.Contains("Macintosh"))
                    {
                        foreach (string item in keywords)
                        {
                            if (agent.Contains(item))
                            {
                                redirect = System.Configuration.ConfigurationManager.AppSettings["WebH5URL"];
                                if (string.IsNullOrEmpty(redirect))
                                {
                                    redirect = new MemberManageBLL().GetPublicConfig("WebH5URL");
                                }
                                break;
                            }
                        }
                    }
                }
                else
                {
                    redirect = System.Configuration.ConfigurationManager.AppSettings["WebFrontURL"];//web.config里配置的url
                    if (string.IsNullOrEmpty(redirect))
                    {
                        redirect = new MemberManageBLL().GetPublicConfig("WebFrontURL");
                    }
                    if (path.ToLower().Contains("hhreg.aspx"))
                        redirect += "/Regist.aspx";
                    if (path.ToLower().Contains("login.aspx"))
                        redirect += path;
                }
                Uri rUrl = new Uri(redirect);
                if ((rUrl.Host == HttpContext.Current.Request.Url.Host && rUrl.Port == HttpContext.Current.Request.Url.Port) || HttpContext.Current.Request.Url.Host.Contains("localhost"))
                    return;
                HttpContext.Current.Response.Redirect(redirect);
            }

    上面是H5跳网页的例子

            public static void CheckAgent()
            {
                string redirect = string.Empty;
                string agent = HttpContext.Current.Request.UserAgent;
                string[] keywords = { "Android", "iPhone", "iPod", "iPad", "Windows Phone", "MQQBrowser" };
                string path = HttpContext.Current.Request.Url.AbsolutePath;
                //排除 Windows 桌面系统 
                if (!agent.Contains("Windows NT") || (agent.Contains("Windows NT") && agent.Contains("compatible; MSIE 9.0;")))
                {
                    //排除 苹果桌面系统 
                    if (!agent.Contains("Windows NT") && !agent.Contains("Macintosh"))
                    {
                        foreach (string item in keywords)
                        {
                            if (agent.Contains(item))
                            {
                                redirect = System.Configuration.ConfigurationManager.AppSettings["WebH5URL"];
                                if (string.IsNullOrEmpty(redirect))
                                {
                                    redirect = new BLL.MemberManageBLL().GetPublicConfig("WebH5URL");
                                }
                                break;
                            }
                        }
                    }
                    if (path.ToLower().Contains("regist.aspx") || path.ToLower().Contains("regcode.aspx"))
                        redirect += "/HHReg.aspx";
                    if (path.ToLower().Contains("login.aspx"))
                        redirect += path;
                }
                else
                {
                    redirect = System.Configuration.ConfigurationManager.AppSettings["WebFrontURL"];
                    if (string.IsNullOrEmpty(redirect))
                    {
                        redirect = new BLL.MemberManageBLL().GetPublicConfig("WebFrontURL");
                    }
                }
                Uri rUrl = new Uri(redirect);
                if ((rUrl.Host == HttpContext.Current.Request.Url.Host && rUrl.Port == HttpContext.Current.Request.Url.Port) || HttpContext.Current.Request.Url.Host.Contains("localhost"))
                    return;
                HttpContext.Current.Response.Redirect(redirect);
            }

    网页跳H5例子

  • 相关阅读:
    [LeetCode] 493. Reverse Pairs 翻转对
    [LeetCode] Super Washing Machines 超级洗衣机
    [LeetCode] Perfect Number 完美数字
    [LeetCode] 483. Smallest Good Base 最小的好基数
    [LeetCode] Sliding Window Median 滑动窗口中位数
    [LeetCode] Diameter of Binary Tree 二叉树的直径
    [LeetCode] 01 Matrix 零一矩阵
    [LeetCode] Convert BST to Greater Tree 将二叉搜索树BST转为较大树
    [LeetCode] Reverse String II 翻转字符串之二
    [LeetCode] Minimum Time Difference 最短时间差
  • 原文地址:https://www.cnblogs.com/nnnnnn/p/11214796.html
Copyright © 2020-2023  润新知