views:

71

answers:

2

I have a web server that is run by a third party. I don't have direct access to the server but I can deploy ASP.NET code to it. I want to detect if that server is running ASP.NET 4 / .NET 4 or not. What is the easiest way to do that? Is there an environmental property somewhere that would tell me? Or should I try to load a particular class that only exists in .NET 4?

+7  A: 

How about printing System.Environment.Version?

Filip Navara
That seems to work. I created a stand-alone test page with a <%= System.Environment.Version %> in it. My only question is, let's say I put that in a folder alongside an existing application with a web.config that was for .NET 3.5. What version would it show?
jkohlhepp
Nevermind that was a stupid question. It would show whatever version of ASP.NET that IIS virtual folder is configured as.
jkohlhepp