How to detect .NET 4 from ASP.NET?
Asked Answered
J

2

6

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?

Janelljanella answered 20/9, 2010 at 13:17 Comment(2)
How's about just asking the third party?Metamorphosis
You'd think that would be easy, wouldn't you? But I have reason to not trust anything they tell me. :-)Janelljanella
P
7

How about printing System.Environment.Version?

Paulpaula answered 20/9, 2010 at 13:20 Comment(2)
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?Janelljanella
Nevermind that was a stupid question. It would show whatever version of ASP.NET that IIS virtual folder is configured as.Janelljanella

© 2022 - 2024 — McMap. All rights reserved.