Search code examples
.netclickonceuser-agentversion-detection

Detecting .NET version without UserAgent string


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.

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

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.

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?

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


Solution

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

    In PHP, you would get this via getenv()

    print getenv('HTTP_X_CLICKONCESUPPORT');
    

    In Perl

    print $ENV{HTTP_X_CLICKONCESUPPORT};
    

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

    (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!)