這裏是MSDN頁,列出了每個值和默認值。
下面的代碼將打開的httpRuntime節programitcly
Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
object o = config.GetSection("system.web/httpRuntime");
HttpRuntimeSection section = o as HttpRuntimeSection;
這段代碼被發現here
而在VB
Dim config As Configuration = WebConfigurationManager.OpenWebConfiguration("~")
Dim o As Object = config.GetSection("system.web/httpRuntime")
Dim section As HttpRuntimeSection = TryCast(o, HttpRuntimeSection)
確保您使用/導入下面的命名空間。
System.Configuration;
System.Web.Configuration;
根據評論編輯。
當調用WebConfigurationManager.OpenWebConfiguration
從MSDN
路徑 類型:System 的虛擬路徑的配置文件。如果爲null,則會打開根Web.config文件。
即使您沒有在您的web.config中定義的httpRuntime,它也是根Web.config,並返回。我已經測試過,沒有定義httpRuntime。
嗯。這直接讀取web.config。我的web.config和我的machine.config沒有這些部分,但我希望有一些DEFAULT設置可以使用該框架進行查詢,即使我選擇不通過添加我的部分來覆蓋這些默認設置網頁配置。 – ChadD 2010-05-18 16:15:04
@George看我的編輯。即使你沒有在web.config中定義它,它也會打開httpRuntime。 – 2010-05-18 16:21:17