判断是否是手机
public static bool checkagent()
{
bool flag = false;
string agent = 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;
}
上一篇: Android 的 so 文件加载机制