The Helper home (www.bkjia.com) Tutorial in asp.net will always encounter the need to read the configuration file, usually to read the database connection string, this simple and practical ConfigurationManager. connectionStrings ["OMPDBConn"]. connectionString is enough, but reading a node like authentication is a little troublesome.
One method described in the web configuration file in the sdk is to use System. web. configuration. webConfigurationManager. openMachineConfiguration () to obtain a Configuraton object, which is web. config description.
Note that when calling this OpenMachineConfiguration () function, you must note that if you enter a string. empty, the default configuration file of asp.net is read, which is displayed on my machine:
C: \ Windows \ Microsoft. NET \ Framework \ v2.0.50727 \ Config \ web. config; if "/" is entered, the configuration file of the wwwroot root directory is read, which is generally: C: \ inetpub \ wwwroot \ web. config. that is to say, if you want to read a program that does not follow the directory, you need to pay special attention to this path.