简体   繁体   English

使用Javascript在带有IE的Windows XP下检测.NET 4.0

[英]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.

相关问题 Windows XP 上的 .Net Framework 4.0 - .Net Framework 4.0 on Windows XP .NET 4.0 Project不能在Windows XP上运行 - .NET 4.0 Project will not run on Windows xp exe 无法在 windows xp 上运行甚至将 .net 更改为 4.0 - exe can't run on windows xp even change .net to 4.0 .NET 4.0在XP上提供了Unknown Exception,但在Windows 7上运行良好 - .NET 4.0 gives Unknown Exception on XP but it working good on Windows 7 Windows 7 + .NET 4.0中“Marshal.StructureToPtr”的访问冲突异常(Windows XP + .NET 3.5正常) - Access violation exception at 'Marshal.StructureToPtr' in Windows 7 + .NET 4.0 (Windows XP + .NET 3.5 works fine) 带有.NET Framework 4.0的Windows XP SP3上的.NET Framework 3.0应用程序 - .NET Framework 3.0 App on Windows XP SP3 with .NET Framework 4.0 如何使用C#4.0检测Windows 8操作系统? - How to detect Windows 8 Operating system using C# 4.0? 在Windows Xp客户端上运行使用.NET 4.5开发的Web应用程序 - Running web application developed using .NET 4.5 on Windows Xp clients 在Windows XP IIS上使用ASP.NET动态数据站点? - Using ASP.NET Dynamic Data site on Windows XP IIS? 在Windows XP和.Net 3.5上使用NamedPipes时发生InvalidOperationException - InvalidOperationException while using NamedPipes on Windows XP and .Net 3.5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM