检测.NET版本没有的UserAgent字符串有的、字符串、版本、NET

2023-09-03 10:23:41 作者:回忆、失晴-

大多数现代浏览器(Chrome浏览器10,火狐4,IE9)都缩短他们的UserAgent标识。其结果是,所支持的.NET版本不再发送给服务器。

Most modern browsers (Chrome 10, Firefox 4, IE9) are all shortening their UserAgent identifiers. As a result, the supported .NET versions are no longer sent to the server.

为了让我们的客户能够使用我们的ClickOnce应用程序,我们需要知道哪些框架是由客户端支持。

In order to allow our customers to use our ClickOnce application, we need to know which frameworks are supported by the client.

Javascript的检测Chrome和Firefox的ClickOnce助手是一个开始(这些现在都没有在Firefox 4),但我们不再有检测客户端是否有.NET 2.0,3.5或4.0安装的方式。

Javascript detection of the Chrome and Firefox ClickOnce helpers are a start (these are now failing in Firefox 4), but we no longer have a way of detecting if the client has .NET 2.0, 3.5 or 4.0 installed.

从用户代理字符串检测Windows平台限制和推理的最有可能的架构(XP = 1.1,Vista的= 2.0,Win7的= 3.5),我们如何能够检测.NET框架的支持?

Barring from detecting the Windows platform from the UserAgent string and inferring the most likely framework (XP = 1.1, Vista=2.0, Win7=3.5), how could we detect .NET framework support?

(我们要prevent的。应用文件下载为我们的大多数客户似乎并没有注意到下载背后弹出式窗口)

(We want to prevent the .application file downloading as most of our clients don't seem to notice the downloading "pop-unders")

推荐答案

这个问题是修复微软。 .NET版本现已返回一个HTTP请求头,X-ClickOnceSupport。

This problem was fixed by Microsoft. The .NET version is now returned as an HTTP request header, "X-ClickOnceSupport".

在PHP中,你将通过GETENV得到这个()

In PHP, you would get this via getenv()

print getenv('HTTP_X_CLICKONCESUPPORT');

在Perl中

print $ENV{HTTP_X_CLICKONCESUPPORT};

在JavaScript的是不可能的,根据this回答。

In JavaScript it is not possible, according to this answer.

(这一切都通过检查Firefox的.NET助理,害得我搜索X-ClickOnceSupport头的code开始。喜欢能够查看源$ C ​​$ C,解决了没有谜!)

(This all started by examining the code of the Firefox .NET Assistant, which led me to search for the "X-ClickOnceSupport" header. Nothing like being able to view the source code to solve a mystery!)