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.
You can use the
Request.Browser.ClrVersionproperty to get the client’s highest .NET version andRequest.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.