我做了一個小小的研究,碰到這個跑:http://msdn.microsoft.com/en-us/library/ms228245.aspxconfigSections的用途是什麼?
所以,如果我理解的正確,最終這是什麼東西做的是包括在項目中使用某些.DLL文件,很像:
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
我猜的區別是,如果你這樣做configSections的方式,你可以通過在webconfig(或其他配置)中創建'name'作爲xml元素來設置一些參數。這是正確的,還是我錯過了什麼?
另外,我注意到,我可以從一個網站的web.config中刪除configSections,它將會運行得很好,特別是以下configSections:
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
我讀書的地方,你能做到這一點,有它仍然運行,因爲configSections在machine.config中也是默認定義的。那麼爲什麼要在網站的web.config中再次定義它呢?我假設用一些自定義設置覆蓋machine.config?有什麼方法可以確定machine.config文件的默認內容是什麼?
好,感謝那是很好的瞭解,但我也想知道究竟這些事情做。例如,我知道,如果我刪除是這樣的:<添加組件=「System.Web.Extensions程序,版本= 1.0.61025.0,文化=中性公鑰= 31bf3856ad364e35」 /> 然後,我將無法訪問任何我的網站中的System.Web.Extensions中的類。如果我從我的web.config中刪除這些配置節(如果它們不在machine.config中),會發生什麼情況 – Trajanus 2010-01-15 18:59:09
@Trajanus,對於延遲感到抱歉。正如你所說的那樣,有一些新的配置部分,比如'machine.Web.Extensions',它們沒有在'machine.config'中定義。這些部分與ASP.NET AJAX服務有關。因此,如果你刪除了他們的定義,你就不能使用它們。如果您不需要它們,請刪除此部分。 – 2010-01-16 08:31:54