学习平台判断是否是手机端

   protected bool isMobilePage(out string path)
        {
            bool ismobi = false;
            string prefix = "/mobile";
            path = this.Request.Url.AbsolutePath;
            if (path.Length >= prefix.Length)
            {
                string pre = path.Substring(0, prefix.Length);
                if (pre.ToLower() == prefix.ToLower()) ismobi = true;
            }
            //如果是手机端页面,则去除/mobile/路径
            if (ismobi) path = path.Substring(prefix.Length);
            if (path.IndexOf(".") > -1)
                path = path.Substring(path.IndexOf("/") + 1, path.LastIndexOf(".") - 1);
            else
                path = path.Substring(path.IndexOf("/") + 1);
            path = path.Replace("/", "\");
            //自定义配置项
            WeiSha.Common.CustomConfig config = CustomConfig.Load(this.Organ.Org_Config);
            bool isNoaccess = false;    //是否禁止访问
            //如果是手机端
            if (ismobi)
            {                
                //如果禁止微信中使用,且又处于微信中时
                if ((config["DisenableWeixin"].Value.Boolean ?? false) && WeiSha.Common.Browser.IsWeixin) isNoaccess = true;
                if ((config["DisenableMini"].Value.Boolean ?? false) && WeiSha.Common.Browser.IsWeixinApp) isNoaccess = true;
                if ((config["DisenableMweb"].Value.Boolean ?? false) && (!WeiSha.Common.Browser.IsAPICloud && !WeiSha.Common.Browser.IsWeixin))
                    isNoaccess = true;
                if ((config["DisenableAPP"].Value.Boolean ?? false) && WeiSha.Common.Browser.IsAPICloud) isNoaccess = true;                
            }
            else
            {
                if ((config["WebForDeskapp"].Value.Boolean ?? false) && !WeiSha.Common.Browser.IsDestopApp) isNoaccess = true;
            }
            //如果被限制访问
            if (isNoaccess) path = "Noaccess";
            return ismobi;
        }

   protected bool isMobilePage(out string path)        {            bool ismobi = false;            string prefix = "/mobile";            path = this.Request.Url.AbsolutePath;            if (path.Length >= prefix.Length)            {                string pre = path.Substring(0, prefix.Length);                if (pre.ToLower() == prefix.ToLower()) ismobi = true;            }            //如果是手机端页面,则去除/mobile/路径            if (ismobi) path = path.Substring(prefix.Length);            if (path.IndexOf(".") > -1)                path = path.Substring(path.IndexOf("/") + 1, path.LastIndexOf(".") - 1);            else                path = path.Substring(path.IndexOf("/") + 1);            path = path.Replace("/", "\");            //自定义配置项            WeiSha.Common.CustomConfig config = CustomConfig.Load(this.Organ.Org_Config);            bool isNoaccess = false;    //是否禁止访问            //如果是手机端            if (ismobi)            {                                //如果禁止微信中使用,且又处于微信中时                if ((config["DisenableWeixin"].Value.Boolean ?? false) && WeiSha.Common.Browser.IsWeixin) isNoaccess = true;                if ((config["DisenableMini"].Value.Boolean ?? false) && WeiSha.Common.Browser.IsWeixinApp) isNoaccess = true;                if ((config["DisenableMweb"].Value.Boolean ?? false) && (!WeiSha.Common.Browser.IsAPICloud && !WeiSha.Common.Browser.IsWeixin))                    isNoaccess = true;                if ((config["DisenableAPP"].Value.Boolean ?? false) && WeiSha.Common.Browser.IsAPICloud) isNoaccess = true;                            }            else            {                if ((config["WebForDeskapp"].Value.Boolean ?? false) && !WeiSha.Common.Browser.IsDestopApp) isNoaccess = true;            }            //如果被限制访问            if (isNoaccess) path = "Noaccess";            return ismobi;        }

原文地址:https://www.cnblogs.com/Jeely/p/11346326.html