What is the purpose of configSections?

I did a little research and came across this: http://msdn.microsoft.com/en-us/library/ms228245.aspx

So, if I understand this correctly, ultimately this is what it does, including some .dlls for use in the project, for example:

<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

And I assume that the difference is that if you do this using configSections, you can set some parameters by creating a "name" later in webconfig (or another configuration) as an xml element. Is this right, or am I missing something?

In addition, I noticed that I can remove configSections from the web.config website and it will work fine, in particular the following configuration sections:

 <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> 

I read somewhere that you can do this and it is still executing because configSections was also defined by default in the machine.config file. So why define it again on web.config? Am I supposed to override machine.config with some user settings? Is there any way to determine what is the default content for machine.config file?

+4
source share
3 answers

You're right. ASP.NET configuration sections are defined in machine.config . This is a hierarchy in which each configuration file overrides the parent element. You can find the machine.config and root web.config in the following directory.

 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG 
+1
source

You define it again to change the behavior of the website.

Suppose you use several different websites and want them to be configured differently for a particular section. This is why they exist in web.config.

0
source

All .NET Framework applications inherit basic configuration settings and default values ​​from a file named systemroot \ Microsoft.NET \ Framework \ versionNumber \ CONFIG \ Machine.config. The Machine.config file is used to configure server settings. Some of these settings cannot be overridden in configuration files that are lower in the hierarchy.

.NET client applications (console and Windows applications) use configuration files called ApplicationName.config to override the inherited settings. ASP.NET applications use configuration files called Web.config to override inherited settings.

The root of the ASP.NET configuration hierarchy is a file called the root Web.config file and is located in the same directory as the Machine.config file. The root Web.config file inherits all the settings in the Machine.config file. The root Web.config file contains settings that apply to all ASP.NET applications that run a specific version of the .NET Framework. Because each ASP.NET application inherits the default configuration settings from the root Web.config file, you only need to create Web.config files for settings that override the default settings.

see Hierarchy and Inheritance of ASP.NET Configuration File

0
source

All Articles