markmnl
markmnl

Reputation: 11426

How to check if client has .net 3.5 Client Profile (or any version of .Net) from web site?

Is there anyway to check from a website if a client has a specific version of .Net installed and which one it is so you can offer them different downloads based on it?

Upvotes: 2

Views: 267

Answers (3)

ocdi
ocdi

Reputation: 445

I discovered this issue recently and IE9 when standards mode doesn't include the CLR versions in the User Agent, as noted in Richard's answer. It seems the only way to get this information server-side is setting compatibility view mode. Alternatively if you wish to preserve standards mode then you will need to get the information via java script.

if (navigator.userAgent.match(/\.NET CLR [234].[05]/)) {
    // do stuff depending on presence
}

You can adjust the version numbers or drop off that bit depending on your needs.

Upvotes: 0

Steve B
Steve B

Reputation: 37660

You can parse the user agent. There is MSDN page that describes the format, especially, take a look at the .NET CLR <version> token.

However, you can guarantee the information will be present and accurate : non MS browser, customized user agent string, paranoid user agent, etc. can be factors for users to remove such information.

[Edit] Probably not an easy things to do, but you can use a setup bootstrapper which will detect the installed version to download the actual setup. Microsoft use this technique for some of their products web installers.

Upvotes: 1

Richard
Richard

Reputation: 108995

Some browsers include this information in the User Agent header, eg. from the log files on a machine with IE8 installed:

Mozilla/4.0+(compatible;+MSIE+8.0;+Windows+NT+6.0;+Trident/4.0;+SLCC1;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.30729;+.NET+CLR+3.5.30729;+.NET4.0C;+.NET4.0E)

However this information is not included in IE9's user agent string.

In general: without trying something on the client you cannot be sure.

Upvotes: 1

Related Questions