Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine the clients .NET framework version in a web application?

Tags:

c#

.net

asp.net

I need to determine the clients .NET framework version in my web application. I'm running in partial trust so I can not read the filesystem or registry (Is there an easy way to check .net framework verison using C#?).

  • System.Environment.Version returns the runtime version, so I can not use that.

  • I cannot use javascript

The only way I can think of at the moment is to try to load a .NET 3.5 dll and catch an exception, but this does not sound very nice.

Any suggestions?

Update:

Request.Browser.ClrVersion and Request.Browser.GetClrVersions() will return the .NET framework version(s) installed on the client.

like image 761
Ezombort Avatar asked Mar 18 '10 08:03

Ezombort


1 Answers

You can use the Request.Browser.ClrVersion property to get the client's highest .NET version and Request.Browser.GetClrVersions() method to get all the installed .NET versions.

These methods simply parse the Request.ServerVariables("HTTP_USER_AGENT") server variable.

But please note that a browser (or user or hacker) may put anything he wishes in the string, so you won't have 100% accuracy.

like image 163
Steven Avatar answered Oct 23 '22 07:10

Steven