简体   繁体   English

IIS7以编程方式在ASP.NET中获取应用程序池版本

[英]IIS7 Programmatically get App Pool version in ASP.NET

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. 我有一个诊断网页,我需要确保以编程方式在ASP.NET中将网站安装在正确的App Pool版本上。

I am running IIS 7.5 Under Windows 7 but the code also have to work under Windows Server 2008 R2. 我在Windows 7下运行IIS 7.5,但代码也必须在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. 但是,从那里,我不知道如何获取App Pool版本。 I've looked at a lot of webpages and forums but I can't quite find the answer. 我看过很多网页和论坛,但找不到答案。 Anyone can help? 有人可以帮忙吗?

Since you are doing it from the runtime how about just returning the .NET version, or System.dll? 既然您是从运行时执行此操作的,那么如何只返回.NET版本或System.dll? If you want to report the version of .NET that is probably a pretty accurate. 如果您要报告.NET的版本,可能非常准确。

Something like: 就像是:

Version version = Environment.Version

The following article shows how to use the ServerManager class to create an application pool and set its properties, including the ManagedRuntimeVersion: 以下文章显示了如何使用ServerManager类创建应用程序池并设置其属性,包括ManagedRuntimeVersion:

Adding an Application Pool to IIS7 programmatically 以编程方式将应用程序池添加到IIS7

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM