ASP.NET Configuration

Discussion in 'ASP.NET' started by MinalS, Sep 22, 2015.

  1. 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:

            <section name = "section1" type = "sectionhandler1" />
            <setting1 attribute1 = ="attribute1" />
            <authentication mode ="Windows" />
    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:

        <section />
        <sectionGroup />
        <remove />
        <clear />
    The elements present in the section handler declarations are:
    1. Remove: The reference to section group and an inherited section is removed
    2. Clear: All the references to the inherited and section group are removed
    3. Section group: The association between the section handler and configuration section is defined
    4. 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:

        < [ add | clear | remove ]  key = " configuration key value" value = "value" />
    Consider an example for adding the name of the student and registration number.

            <add key = "appName" value = "John Smith" />
            <add key = "appRegNo" value = "10-30-20101" />
    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.

    <?xml version = "1.0" encoding = ‘utf – 8’ ?>
                <clear />
                <add name = "Name1" providerName = "System.Data.ProviderName" connectionString ="Connection String Name;" />

    The root element in the configuration section consisting of the configuration elements is defined.

    The various attributes, parent and child elements are described below:
    1. authentication : The authentication support is provided to the user.
    2. anonymousIdentification: The identification is configured for application authorization.
    3. authorization: The authorization support is provided
    4. compilation: All the compilation settings needed are provided to the user
    5. caching: The cache settings for the configuration are provided
    6. customErrors: The custom error messages are shown
    7. globalization: The globalization elements are defined
    8. healthMonitoring: The health monitoring for the application are described
    9. httpHandlers: The incoming URL requests are mapped to IHttpHandler classes
    10. httpCookies: The properties for the cookies are configured
    11. identity: The application identity for the web application is described
    12. membership: The parameters for handling the user account for ASP.NET membership
    13. pages: The page specific configuration settings are described
    14. roleManager: Role management for an application is defined
    15. securityPolicy: The valid mappings for the name security levels are defined
    16. trace: The trace service for an ASP.NET application is described
    17. urlMappings: The mapping is done with the user friendly URL.
    18. webParts: The web parts personalization provider is defined
    19. webservices: The setting of XML web service created using an ASP.NET application

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice