zoukankan      html  css  js  c++  java
  • ASP.NET判断是否为手机登录

            protected void Page_Load(object sender, EventArgs e)
            {
                MobileHandle();
               }

    页面加载时候判断是否为手机登录

            protected void MobileHandle()
            {
                string mobilePath = PublicFunction.GetConfigValue("MobilePath");//手机页面的路径
                if (!string.IsNullOrEmpty(mobilePath))
                {
                    bool isMobile = PublicFunction.IsMobile(Request.UserAgent);
                    if (isMobile)
                    {
                        Response.Redirect(mobilePath);//为手机登录的话跳转手机页面
                    }
                }
            }
      public class PublicFunction
        {
            static string[] mobileTag = { "iphone", "ios", "ipad", "android", "mobile" };
    
            /// <summary>
            /// 判断是否是手机打开
            /// </summary>
            /// <param name="userAgent">用户浏览器代理信息</param>
            /// <returns></returns>
            public static bool IsMobile(string userAgent)
            {
                bool result = false;
                userAgent = userAgent.ToLower();
                foreach (string sTmp in mobileTag)
                {
                    if (userAgent.Contains(sTmp))
                    {
                        result = true;
                        break;
                    }
                }
                return result;
            }
    }
  • 相关阅读:
    openstack生产要素
    None
    nginx优化 tbc
    zabbix开源监控解决方案
    HUGO & Hexo
    mysql数据库-运维合集
    Zabbix Agent ver5.0 批量部署
    CRI containerd
    zabbix聚合图形与Grafana图形展示
    zabbix 监控tomcat
  • 原文地址:https://www.cnblogs.com/RambleLife/p/9081241.html
Copyright © 2011-2022 走看看