1

我有一个诊断网页,我需要确保该网站以编程方式在 ASP.NET 中安装在正确的应用程序池版本上。

我在 Windows 7 下运行 IIS 7.5,但代码也必须在 Windows Server 2008 R2 下运行。

我知道如何通过以下两种方式获取 App Pool 名称:

 // 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"];

但是,从那里,我不知道如何获得 App Pool 版本。我查看了很多网页和论坛,但我找不到答案。任何人都可以帮忙吗?

4

2 回答 2

1

既然您是从运行时执行的,那么只返回 .NET 版本或 System.dll 怎么样?如果您想报告 .NET 的版本,那可能是相当准确的。

就像是:

Version version = Environment.Version
于 2013-10-23T17:52:52.523 回答
0

以下文章展示了如何使用 ServerManager 类创建应用程序池并设置其属性,包括 ManagedRuntimeVersion:

以编程方式将应用程序池添加到 IIS7

于 2013-10-23T16:43:34.930 回答