Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# IIS7以编程方式在ASP.NET中获取应用程序池版本_C#_Asp.net_Iis_Iis 7_Iis 8 - Fatal编程技术网

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

C# IIS7以编程方式在ASP.NET中获取应用程序池版本,c#,asp.net,iis,iis-7,iis-8,C#,Asp.net,Iis,Iis 7,Iis 8,我有一个诊断网页,我需要确保在ASP.NET中以编程方式将网站安装在正确的应用程序池版本上 我在Windows 7下运行IIS 7.5,但代码也必须在Windows Server 2008 R2下运行 我知道如何通过以下两种方式获取应用程序池名称: // First way to do it string name = System.Environment.GetEnvironmentVariable("APP_POOL_ID", System.EnvironmentVariableTarg

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

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

我知道如何通过以下两种方式获取应用程序池名称:

 // 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"];
然而,从那里,我不知道如何获得应用程序池版本。我看过很多网页和论坛,但我找不到答案。
任何人都可以提供帮助?

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


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


既然您是在运行时执行此操作,那么只返回.NET版本或System.dll如何?如果您想报告.NET的版本,这可能是一个非常准确的方法

比如:

Version version = Environment.Version

既然您是从运行时执行此操作,那么只返回.NET版本或System.dll如何?如果您想报告.NET的版本,这可能是一个非常准确的方法

比如:

Version version = Environment.Version

这听起来可能是新手,但如果客户端在安装我的网站时意外选择了ASP.NET v2.0应用程序池,但我的网站项目和web.config中都有.NET Framework 4.5,我会将2.0或4.5作为Environment.Version吗?我需要能够告诉客户端他选择了错误的池应用程序版本。这听起来可能有些生疏,但如果客户端在安装我的网站时意外选择了ASP.NET v2.0应用程序池,但我的网站项目和web.config中都有.NET Framework 4.5,我会将2.0或4.5作为Environment.version吗?我需要能够告诉客户端他选择了错误的池应用程序版本。完整诊断网页?完整诊断网页?