判断手机端还是pc端

 public static bool CheckIsMobile()
{
bool flag = false;
string agent = SystemWeb.HttpContext.Current.Request.UserAgent;
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))
{
flag = true;
break;
}
}
}
}
return flag;
}
 public ActionResult Login(string url)
{
if (CheckIsMobile())
{
return RedirectToAction("PhoneLogin");
}
}
上一篇:CSS基础篇---字体属性(4)


下一篇:明星级大作,首轮融资一千万刀,基于Web3.0的去中心化邮箱:Dmail