In the past, the most headache was the configuration string, because my machine was very slow, slow, and slow to a level where I could just install vs, so when I debug the program, it usually takes one second to make a small mistake. However, to see the result, you have to wait until the last minute (if the computer gives me a face, it will take longer ), that's a nightmare. Haha, but: although this computer has been eliminated (and a new hacker _ ^ has been given), I have never been willing to throw it away, keep it for Internet use, ^ _ ^, because he gave me the habit of making few mistakes. No way !! If others say that I have made fewer mistakes, I will return a sentence: No way, Lao Tzu is forced !!
(1). Web. config is stored in XML format. configuration files are classified into the following formats:
1. Configuration section handler Declaration
Feature: it is located at the top of the configuration file and included in the <configsections> flag.
2. Specific Application configuration
Feature: It is located in <deleetting>. You can define global constant settings and other information of an application.
3. Configuration section settings
Features: In the <system. Web> section, you can control Asp.net runtime behaviors.
4. Configure the section group
Feature: You can use the <sectiongroup> label to customize the group, which can be placed inside <configsections> or other <sectiongroup> labels.
(2). Configuration section
1. <configuration> section
Root element, and other sections are inside it.
2. <deleetting> section
This section defines application settings. You can also set some uncertain settings based on your actual situation.
Usage:
I.
<Deleetask>
<Add key = "conntction" value = "Server = 192.168.85.66; userid = sa; Password =; database = Info;"/>
<Deleetask>
A connection string constant is defined, and the connection string can be modified in actual application without modifying the program code.
Ii. <deleetask>
<Add key = "errpage" value = "error. aspx"/>
<Deleetask>
Defines an error redirect page.
3. <compilation> section
Format:
<Compilation
Defaultlanguage = "C #"
DEBUG = "true"
/>
I. default language: defines the background code language. You can select C # And VB.net.
When iidebug is set to true, aspx debugging is started; if it is set to false, aspx debugging is not started, so the application program can be improved.
Performance. Generally, programmers are set to true during development and false when handed over to customers.
4. <customerrors> section
Format:
<Customerrors
Mode = "remoteonly"
Defaultredirect = "error. aspx"
<Error statuscode = "440" Redirect = "err0000page. aspx"/>
<Error statuscode = "500" Redirect = "err500page. aspx"/>
/>
I. Mode: it has three states: On, off, And remoteonly. On indicates that custom information is always displayed; Off indicates that detailed Asp.net error information is always displayed; remoteonly indicates that custom information is only displayed for users not running on the Local Web server.
Ii. defaultredirect: the URL used for redirection when an error occurs. Optional.
Iii. statuscode: indicates the error status code, indicating a specific error status.
Iv. Redirect: the URL of the error redirection.
5. <globalization> section
Format:
<Globalization
Requestencoding = "UTF-8"
Responseencoding = "UTF-8"
Fileencoding = "UTF-8"
/>
I. requestencoding: used to check the encoding of each request.
Ii. responseencoding: used to check the encoding of the returned response content.
Iii. fileencoding: used to check the default encoding for parsing files such as aspx and asax.
6. <sessionstate> section
Format:
<Sessionstate
Mode = "inproc"
Stateconnectionstring = "TCPIP = 127.0.0.1: 42424"
Sqlconnectionstring = "Data Source = 127.0.0.1; trusted_connection = yes"
Cookieless = "false"
Timeout = "20"
/>
I. Mode: status options include off, inproc, StateServer, and sqlserver.
Ii. stateconnectionstring: Specifies the name of the server in which the Asp.net application stores the remote session status. The default value is local.
Iii. sqlconnectionstring: When a database in session status is used, set the connection string here.
Iv. cookieless: if it is set to true, the cookie session status is not used to identify the customer. Otherwise, the opposite is true.
V. Timeout: used to define the time for storing session status. If the duration is exceeded, the session is automatically terminated.
7. <authentication> section
Format:
<Authentication mode = "forms">
<Forms name = ". aspxuserdemo" loginurl = "login. aspx" Protection = "all" timeout = "30"/>
</Authentication>
<Authorization>
<Deny users = "? "/>
</Authorization>
I. Windows: using IIS Authentication
Ii. Forms: use form-based authentication
Iii. Passport: Passport cookie Authentication Mode
Iv. None: no verification method is used.
Meaning of the attributes of embedded forms nodes:
I. Name: Specifies the name of the HTTP cookie that completes authentication.
Ii. loginurl
Iii. Protection: Specifies the cookie data protection method.
It can be set to: All none encryption validation.
A. All indicates data encryption and verification of validity.
B. None indicates that the cookie is not protected.
C. Encryption indicates encryption of cookie content
D. Validation indicates that the cookie content is validated.
Iv. Timeout: Specifies the cookie expiration time. After timeout, you must log on again.
Web. config is of course used to configure websites. Many things can be set here.
The following is a brief introduction.
Web. config is an XML document (now more and more popular with XML for configuration files). The root element is configuration and then contains a system. at the third level, the Web node sets various web pages for the site. there are a lot of labels that can be set in config, so we will give a brief introduction and you can check the labels when using them.
Custom settings in the web system I often use it to save some of the database's connection data and read it easily.
Browser settings, such as whether to allow Java Applet...
Compilation Method
Customize the flag pointed to when an error occurs. This prevents exposure of important messages.
Defines the global settings of the site, mostly related to Syntax
The HTTP module set for the site allows the system to define its own, which is used in URL rewrite.
Set the cookie Encryption Method
Wow, the way apsx works is too much.
Session Processing Method
This setting is used when WebService is used.
Example of appsettings
<Deleetask>
<Add key = "DSN" value = "Server = localhost; uid = sa; database = northwind"/>
</Appsettings>
In this case, you can use string odsn = configurationsettings. etettings ["DSN"]; to represent the connection string.