ASP. NET configuration file web. config

Source: Internet
Author: User
Tags configuration settings
1. Understand that the Web. config file web. config is an XML text file used to store ASP. NET web applications. Program Configuration information (for example, the most common setting of ASP. NET web application authentication method), it can appear in every directory of the application. When you use VB. after creating a web application, a default web application is automatically created in the root directory by default. config file, including the default configuration settings. All subdirectories inherit its configuration settings. If you want to modify the configuration settings of a subdirectory, you can create a web. config file under the subdirectory. It can provide configuration information other than the configuration information inherited from the parent directory, or rewrite or modify the settings defined in the parent directory. Modifications to the Web. config file at runtime can take effect without restarting the Service (note: the exception in <processmodel> section ). Of course, the Web. config file can be expanded. You can customize new configuration parameters and write the configuration section handler to process them. Ii. All of the following Code All must be in <configuration> <system. web> and </system. for the purpose of learning, the following examples omit the XML mark 1 and <authentication> section: Configure ASP. net authentication support (Windows, forms, passport, none ). This element can only be declared at the computer, site, or application level. The <authentication> element must be used with the <authorization> section. Example: In the following example, the website is configured for form-based authentication. When a user who does not log on to the website that requires authentication, the webpage automatically jumps to the logon webpage. <Authentication mode = "forms"> <forms loginurl = "logon. aspx "name = ". formsauthcookie "/> </authentication> the element loginurl indicates the name of the login webpage, and name indicates the cookie name 2. <authorization> function: control Access to URL resources from clients (for example, Anonymous Users are allowed ). This element can be declared at any level (computer, site, application, subdirectory or page. Must be used with the <authentication> section. Example: <authorization> <deny users = "? "/> </Authorization> Note: You can use user. identity. to obtain the authenticated user name. You can use the web. security. formsauthentication. the redirectfromloginpage method redirects authenticated users to the page the user just requested. for specific examples, see: Forms verification http://www.51aspx.com/websample/dataauth.aspx3and <compilation> section function: Configure ASP.. net. The default debug attribute is "true ". after the program is compiled and delivered for use, set it to true (web. the config file is described in detail. Examples are omitted here.) 4. <customerrors>: Asp.. NET applications provide information about custom errors. It is not applicable to errors in XML Web Services. Example: When an error occurs, redirect the webpage to the custom error page. <Customerrors defaultredirect = "errorpage. aspx" mode = "remoteonly"> </customerrors> the defaultredirect element indicates the name of the custom error webpage. Mode element: displays custom (friendly) information for users not running on the Local Web server. 5.
Related Article

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.