Detecting .NET version without UserAgent string
Asked Answered
B

4

7

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")

Baliol answered 12/4, 2011 at 14:35 Comment(0)
T
2

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

Tenor answered 26/9, 2011 at 21:0 Comment(1)
This is true for the Firefox plugin ".NET Framework Assistant" but not for IE 9 & IE 10Calton
G
4

navigator.userAgent gives you the extended UA string at least on IE9

Grannia answered 18/4, 2011 at 9:2 Comment(3)
This is headed in the right direction: IE9, Chrome12 and FF3.6 emit the .NET string properly via this method. Sadly, FF4 does not. Thanks for your suggestion.Baliol
In our observation, navigator.userAgent and UserAgent header sent to server are exactly the same in all compatibility modes of IE9. In IE9 mode, .NET version is missing.Splashdown
I can confirm than in IE9, console.log(navigator.userAgent); returns all framework versions. Tested on jsfiddle.net.Kuban
T
2

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

Tenor answered 26/9, 2011 at 21:0 Comment(1)
This is true for the Firefox plugin ".NET Framework Assistant" but not for IE 9 & IE 10Calton
E
1

I don't see a way to do this. If the browser doesn't tell your server which frameworks are installed then you don't have any other way to find out.

Elf answered 12/4, 2011 at 14:51 Comment(2)
Is it not possible to create a Silverlight widget that detects the installed frameworks and expose the results via javascript?Baliol
That assumes they have Silverlight installed. There are lots of ways you COULD detect it, but none of them are foolproof, and all of them have various failure scenarios.Pollock
M
1

The way I got around this problem was to send back a response header telling the browser to function in compatibility then detecting the framework version with javascript on the navigator.userAgent.

Page Code-behind:

Response.Headers.Add("X-UA-Compatible", "IE=7");

Javascript on the page

// js to detect .net 3.5
// if it evaluates to true, then the user has .NET 3.5 installed
alert(navigator.userAgent.search(/\.NET.*?3\.5[\.\da-z]*?;/i) > -1);
Metaphosphate answered 1/11, 2011 at 20:5 Comment(1)
Thanks for your contribution, but our main problem is that newer non-IE browsers don't return the .NET versions in the userAgent string anymore.Baliol

© 2022 - 2024 — McMap. All rights reserved.