在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
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; } } 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; } } |
请发表评论