【问题标题】:IIS7 Programmatically get App Pool version in ASP.NETIIS7 以编程方式在 ASP.NET 中获取应用程序池版本
【发布时间】:2013-10-23 15:44:10
【问题描述】:

我有一个诊断网页,我需要确保该网站以编程方式在 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 版本。我查看了很多网页和论坛,但我找不到答案。 有人可以帮忙吗?

【问题讨论】:

  • 完整 诊断网页 ?

标签: c# asp.net iis iis-7 iis-8


【解决方案1】:

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

类似:

Version version = Environment.Version

【讨论】:

  • 这听起来可能是新手,但如果客户在安装我的网站时不小心选择了 ASP.NET v2.0 应用程序池,但我的网站项目和 web.config 都包含 .net Framework 4.5,我会得到 2.0 还是 4.5 作为 Environment.Version?我需要能够告诉客户他选择了错误的 Pool 应用程序版本。
【解决方案2】:

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

Adding an Application Pool to IIS7 programmatically

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-02
    • 2012-04-23
    • 2022-07-26
    • 2022-06-17
    • 1970-01-01
    相关资源
    最近更新 更多