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?
How to detect .NET 4 from ASP.NET?
Asked Answered
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
How about printing System.Environment.Version?
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.