Discussion on the Web. config configuration file

Source: Internet
Author: User

You can directly modify the data and add the data connection object to Web. config without re-compiling,

After modification, you need to re-compile

1. All configurations must be placed between <configuration> </configuration>,

2. <ettings> </appsettings> is a user-defined configuration, which is generally used to set some constants;

<Add> </Add> is used to add constants. The key is the name of a constant, and the value is the value of a constant.

System. configuration. configurationsettings. etettings ["key"] to reference

For example, the following database connection example ----------
] <Appsettings>
<Add key = "con" value = "Server = 127.0.0.1; database = dat; SA = sa; Pwd = sa"/>
</Appsettings>
Available on other pages
Sqlconnection con = new sqlconnection (system. configuration. configurationsettings. etettings ["con"]);
Con. open ();
Sqlcommand cmd = new sqlcommand ("select * from me", con );
This. gridview1.datasource = cmd. executereader ();
This. gridview1.databind ();

In this way, the modification is very convenient, and you do not need to re-compile it after each modification. The effect is the same as that of the class.

3. <location> </location> indicates that the region tag Path = "A" indicates that the following tag only applies to directory.

4. <system. Web> </system. Web> is the configuration of the entire application.
For example, set a buffer in it.

<Pages buffer = "true"/> // enable buffer (buffer the processed data on the server before processing all the data, otherwise, process a little bit and send a '16 K as a unit '. By default, the buffer is enabled.
When the following configuration file fails, it is redirected to a special error page. mode = "remoteonly" indicates that the detailed information can be seen on the server side, and others can be redirected to a special page.

If mode = "on", both the server and client fields are directed to genericerrorpage.htm.
<Customerrors mode = "remoteonly" defaultredirect = "genericerrorpage.htm">
<Error statuscode = "403" Redirect = "noaccess.htm"/>
<Error statuscode = "404" Redirect = "filenotfound.htm"/>
</Customerrors>

<Compilation DEBUG = "true"> during compilation, DEBUG = "true" is easy to debug, but must be changed to false at release.

Authentication: <Authentication mode = "Windows"/> by default, it is based on Windows authentication. There are four types of windows, forms, non, and passport. We generally use forms (cookies and sessions)-based
<Authentication mode = "forms">
<Forms loginurl = "login. asp" name = "Boyang" Protection = "all"> </Forms>
</Authentication>
<Authorization>
<Deny users = "?, A "/> anonymous and a are not allowed
<Allow users = "B"/>B can
</Authentication>

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.