Overview of Configuration In the machine.config file, the values specific to the machine are defined. The settings of the configuration are managed by the system administrator. Users cannot access these files. It is present in the %runtime install path%\Config directory. The web.config file is used for overriding the default values. The configuration file can be extended locally, override or restrict the settings. The configuration element is the root node. The configuration handler and configuration section settings area are present in the configuration file. The syntax for the configuration file is as shown below: Code: <configuration> <configSections> <section name = "section1" type = "sectionhandler1" /> </configSections> <section1> <setting1 attribute1 = ="attribute1" /> </section1> <system.web> <authentication mode ="Windows" /> </system.web> </configuration> Section handler declarations The section handlers are present in the <configSections> tags. The name and the file in which the configuration is present is specified. The configuration data is present. The syntax for the configuration sections is: Code: <configSections> <section /> <sectionGroup /> <remove /> <clear /> </configSections> The elements present in the section handler declarations are: Remove: The reference to section group and an inherited section is removed Clear: All the references to the inherited and section group are removed Section group: The association between the section handler and configuration section is defined Section: The association in the configuration element and section handler is defined Application and connection settings The application settings helps user to store the application name value pairs. The <appSettings> element is used for customizing the web application. User can add, remove or clear using the key / value pair inside the <appSettings> element. The general syntax for the application settings is as shown below: Code: <appSettings> < [ add | clear | remove ] key = " configuration key value" value = "value" /> </appSettings> Consider an example for adding the name of the student and registration number. Code: <configuration> <appSettings> <add key = "appName" value = "John Smith" /> <add key = "appRegNo" value = "10-30-20101" /> </appSettings> </configuration> Connection settings are saved in key / value pair in an application configuration file. The elements can be add, remove and clear are the child elements. The following code example demonstrates the use of the connection string in the configuration file. Code: <?xml version = "1.0" encoding = ‘utf – 8’ ?> <configuration> <connectionStrings> <clear /> <add name = "Name1" providerName = "System.Data.ProviderName" connectionString ="Connection String Name;" /> </connectionStrings> </configuration> System.Web.Element The root element in the configuration section consisting of the configuration elements is defined. Code: <system.web> <anonymousIdentification> <authentication> <authorization> <browsercaps> <caching> <clientTarget> <compilation> <customErrors> <deployment> <deviceFilters> <globalization> <healthMonitoring> <hostingEnvironment> <httpCookies> <httpHandlers> <httpModules> <httpRuntime> <identity> <machinekey> <membership> <mobileControls> <pages> <processModel> <profile> <roleManager> <securityPolicy> <sessionPageState> <sessionState> <siteMap> <trace> <trust> <urlMappings> <webControls> <webParts> <webServices> <xhtmlConformance> </system.web> The various attributes, parent and child elements are described below: authentication : The authentication support is provided to the user. anonymousIdentification: The identification is configured for application authorization. authorization: The authorization support is provided compilation: All the compilation settings needed are provided to the user caching: The cache settings for the configuration are provided customErrors: The custom error messages are shown globalization: The globalization elements are defined healthMonitoring: The health monitoring for the application are described httpHandlers: The incoming URL requests are mapped to IHttpHandler classes httpCookies: The properties for the cookies are configured identity: The application identity for the web application is described membership: The parameters for handling the user account for ASP.NET membership pages: The page specific configuration settings are described roleManager: Role management for an application is defined securityPolicy: The valid mappings for the name security levels are defined trace: The trace service for an ASP.NET application is described urlMappings: The mapping is done with the user friendly URL. webParts: The web parts personalization provider is defined webservices: The setting of XML web service created using an ASP.NET application