1

I have a diagnostic web page and I need to ensure that the website was installed on the right App Pool version programmatically in ASP.NET.

I am running IIS 7.5 Under Windows 7 but the code also have to work under Windows Server 2008 R2.

I know how to get App Pool name with those two ways:

 // First way to do it
 string name = System.Environment.GetEnvironmentVariable("APP_POOL_ID", System.EnvironmentVariableTarget.Process);

 // Second way to do it
 string name = HttpContext.Current.Request.ServerVariables["APP_POOL_ID"];

However, from there, I don't know how to get the App Pool version. I've looked at a lot of webpages and forums but I can't quite find the answer. Anyone can help?

1
  • full diagnostic web page ? Commented Nov 24, 2015 at 22:48

2 Answers 2

1

Since you are doing it from the runtime how about just returning the .NET version, or System.dll? If you want to report the version of .NET that is probably a pretty accurate.

Something like:

Version version = Environment.Version
Sign up to request clarification or add additional context in comments.

1 Comment

This may sound newbie, but if a client accidentally choose an ASP.NET v2.0 Application pool when installing my website, but my website project and web.config both have .net Framework 4.5 in it, will I get 2.0 or 4.5 as Environment.Version? I need to be able to tell the client he chose the wrong Pool application version.
0

The following article shows how to use the ServerManager class to create an application pool and set its properties, including the ManagedRuntimeVersion:

Adding an Application Pool to IIS7 programmatically

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.