我有一个网站,我用过Flash应用程序。这个Flash应用程序没有出现在iPad和IPhone.if操作系统Ipad或Iphone我想显示javascript application.i'm使用下面的代码,但这个代码只获取平台Win32NT等信息。
OperatingSystem os = Environment.OSVersion;
os.Platform.ToString();
答案 0 :(得分:2)
使用Request.UserAgent。那会给你你需要的东西。请注意,UserAgent可能会返回错误信息,因为浏览器可以允许您更改此信息。
Also check out this article Detecting a mobile browser in ASP.NET
if (Request.UserAgent.IndexOf("Windows NT 5.1") > 0)
{
//xp
}
else if (Request.UserAgent.IndexOf("Windows NT 6.0") > 0)
{
//VISTA
}
else if (Request.UserAgent.IndexOf("Windows NT 6.1") > 0)
{
//7
}
答案 1 :(得分:1)
private string getOS()
{
string os = null;
if (Request.UserAgent.IndexOf("Windows NT 5.1") > 0)
{
os ="Windows XP";
return os;
}
else if (Request.UserAgent.IndexOf("Windows NT 6.0") > 0)
{
os= "Windows Vista";
return os;
}
else if (Request.UserAgent.IndexOf("Windows NT 6.1") > 0)
{
os = "Windows 7";
return os;
}
else if (Request.UserAgent.IndexOf("Intel Mac OS X") > 0)
{
//os = "Mac OS or older version of Windows";
os = "Intel Mac OS X";
return os;
}
else
{
os = "You are using older version of Windows or Mac OS";
return os;
}
}
答案 2 :(得分:0)
您必须检查Request.UserAgent以获取操作系统信息,请参阅此文章:http://dnohr.dk/aspnet/how-to-detect-browser-operating-system-os-with-aspnet
OperatingSystem os = Environment.OSVersion;
os.Platform
返回托管asp.net站点的服务器的操作系统......