ASP. config (configuration API)

Source: Internet
Author: User

This time we discuss reading the settings values that focus primarily on the following Web. config configuration file.

1, <connectionstring/> The connection string read.

2, <appsettings/> Application Set the value of the read.

3, <mailsettings/>SMTP Mail Set the value of reading.

In the discussion read the above 3 node configuration Money Let's talk about the following 3 classes:

1, Configuration Class (System.Configuration.Configuration).

2, WebConfigurationManager Class (System.Web.Configuration.WebConfigurationManager).

3, ConfigurationManager Class (System.Configuration.ConfigurationManager).

The following is a general introduction to the features of these 3 classes.

1. Configuration class:

You can treat a configuration class as a config ontology for a. NET application, including Web or Windows-based applications, through which you visit the Web. config file of an ASP. Web site or the app. Config file for a Windows Form project. But the configuration class must be paired with the WebConfigurationManager or ConfigurationManager class, to see if the application is an ASP. NET or Windows Form type. NET uses the WebConfigurationManager class, Windows form uses the ConfigurationManager class.

2, WebConfigurationManager class:

The WebConfigurationManager class is to provide access to the Web. config, for example, to open a part of Web. config (section) in the WebConfigurationManager class and return it to the configuration class for processing.

3, ConfigurationManager Class

The ConfigurationManager class provides access to app. Config, for example, by opening a section of app. Config in the ConfigurationManager class and then returning to the configuration class for processing.

Summary: The final collocation of the use of the way.

1), ASP. NET Web page: Configuration Class +webconfigurationmanager class.

2), Windows Forms Type: Configuration Class +configurationmanager class.

Note:

A, although WebConfigurationManager and ConfigurationManager class functions are interoperability, but Microsoft construction is clearly differentiated use.

B, WebConfigurationManager and ConfigurationManager all belong to static class, can be taken directly, do not need new a instance instance.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.