2010-03-31 85 views

回答

3

您可以檢查註冊表讀取值

HKEY_LOCAL_MACHINE\Software\Microsoft\InetStp\Components\WMICompatibility 

,或者可以輸出中servermanagercmd的內容到一個XML文件,並解析文件尋找IIS6兼容性組件

ServerManagerCmd -query [SaveFile.xml] 

如果您在R2上執行此操作,servermanagercmd現在已被棄用,所以您可能想使用powershell來實現相同的檢查。 下面是一些PowerShell的例子,在這種情況下遠程完成http://www.techmumbojumblog.com/?p=217

從以前的答案的WMI方法可能是一樣好,espcialy如果你有更多的配置任務,對IIS進行,驗證了兼容性工具後安裝。

順便說一句,如果你發現沒有被兼容組件處理的配置設置,這裏是我發現從C#這樣做,我在配置通過WMI早在IIS6在網站級別和下(網站運行良好,虛擬目錄和池),但爲了配置Web服務器級別,我必須使用iis7安裝的api,System32 \ inetsrv中的Microsoft.Web.Administration.dll。

using Microsoft.Web.Administration; 
+0

http://www.techmumbojumblog.com/?p=217獲取404錯誤 – Kiquenet 2014-01-13 10:18:23

+0

使用Powershell的最終解決方案? – Kiquenet 2014-01-13 11:49:05

1

請有人給出一個很好的答案! 動機,這裏是一個非常不好回答=)

// Ok, this is stupid, but I can't find any other way to do this 
// Detect whether we're in integrated mode or not 
#warning GIANT HACK FOR IIS7 HERE 
try 
{ 
    var x = HttpContext.Current.CurrentNotification; 
    _isIntegratedMode = true; 
} 
catch (PlatformNotSupportedException) 
{ 
    _isIntegratedMode = false; 
} 
catch (NullReferenceException) 
{ 
    _isIntegratedMode = true; 
} 

這正是我們的代碼目前確實摸不着頭腦(是的,我知道這是我很不 - 因此警告)