[英]Detect .NET 4.0 under Windows XP with IE using Javascript
I have a web page that needs to detect if .NET is installed on the user's computer. 我有一个网页,需要检测用户计算机上是否安装了.NET。 I don't particularly care about the version of .NET installed. 我并不特别在意安装的.NET版本。 Detection is done via Javascript. 通过Javascript完成检测。 Various Googling point to looking for ".NET CLR" in the user agent string. 各种谷歌搜索指向在用户代理字符串中寻找“ .NET CLR”。 This works well for almost all OS/IE/.NET combinations. 这几乎适用于所有OS / IE / .NET组合。 Today I found one that it does not work for. 今天,我发现它不起作用。
Under Windows XP SP3, IE 8 and .NET 4.0 I get the following for the user agent: 在Windows XP SP3,IE 8和.NET 4.0下,用户代理得到以下信息:
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET4.0C; .NET4.0E)
Before I simply add a check for something like ".NET4.0" I wanted to confirm that this is the proper user agent string I should be getting for my browser/OS/.NET combination above. 在我简单地添加诸如“ .NET4.0”之类的检查之前,我想确认这是我上面的浏览器/OS/.NET组合应获取的正确的用户代理字符串。 Does that user agent string look right? 该用户代理字符串看起来正确吗? Any other .NET identifiers I should be looking for when considering other Windows OS/IE/.NET combinations? 在考虑其他Windows OS / IE / .NET组合时我应该寻找其他的.NET标识符吗?
Thanks. 谢谢。
NET CLR is what you should be looking for indeed.You can check it by javascript too at any point inside you code this way: NET CLR确实是您要找的东西。您也可以在javascript的任何位置通过以下方式检查它:
if ((navigator.userAgent.indexOf(".NET CLR")>-1))
alert ("CLR available " +navigator.userAgent);
else
alert(".NET SDK/Runtime is not available for us from within " + <BR> "your web browser or your web browser is not supported." + <BR> " Please check with http://msdn.microsoft.com/net/ for " + <BR> "appropriate .NET runtime for your machine.");
as shown here: detecting .net availability Be careful tough,user agents can be modified.Even tough your normal user won't most probably 如下所示: 检测.net可用性小心谨慎,可以修改用户代理。即使艰难,普通用户也不太可能
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.