Asp. NET configuration file Web. config detailed explanation

Source: Internet
Author: User
Tags configuration settings

I. Understanding the Web. config file Web. config file is an XML text file that is used to store configuration information for an ASP. NET Web application, such as the most common settings for how to authenticate the ASP. It can appear in every directory in the application. When you create a new Web application through vb.net, by default, a default   Web. config file is automatically created in the root directory, including the default configuration settings, and all subdirectories inherit its configuration settings. If you want to modify the configuration settings for subdirectories, you can create a new Web. config file under that subdirectory. It can provide configuration information other than the configuration information inherited from the parent directory, or you can override or modify the settings defined in the parent directory. Modifications to the Web. config file at run time do not need to restart the service to take effect (note:<processmodel> section exception). Of course, the Web. config file can be extended. You can customize the new configuration parameters and write configuration section handlers to process them. Ii. Web. config profile (default configuration settings) All of the following code should be located in <configuration><system.web> and </system.web></ Between configuration>, for the purposes of learning the following example omits this XML tag 1, <authentication> section Role: Configure ASP. NET authentication support (for Windows, Forms, PassPort And none of the four). This element can only be declared at the machine, site, or application level. <authentication> elements must be used in conjunction with the <authorization> section. Example: The following example configures a site for forms-based authentication, and when no logged-on user accesses a webpage that requires authentication, the webpage automatically jumps to the landing page.   <authentication mode= "Forms" >   <forms loginurl= "logon.aspx" name= ". Formsauthcookie "/>   </authentication>  where element loginurl represents the name of the landing page, name means cookie Name 2, < Authorization>: Controlling the Client for a URL resourceAccess (such as allowing anonymous users access). This element can be declared at any level (computer, site, application, subdirectory, or page). Must be used in conjunction with the <authentication> section. Example: The following example disables access for anonymous users   <authorization>   <deny users= "?" />   </authorization>  Note: You can use User.Identity.Name to get the current user name that has been verified, and you can use   Web. The Security.FormsAuthentication.RedirectFromLoginPage method redirects the authenticated user to the page that the user just requested. For specific examples, please refer to: Forms verification http://www.51aspx.com /WEBSAMPLE/DATAAUTH.ASPX3, <compilation>: Configures all compilation settings used by ASP. The default Debug property is "true". It should be set to true after the program has been compiled for delivery (the Web. config file has a detailed description, omitting the example here) 4, <customErrors> Role: for ASP. The application provides information about custom error messages. It does not apply to errors that occur in XML Web services. Example: When an error occurs, the Web page jumps to the custom error page.   <customerrors defaultredirect= "errorpage.aspx" mode= "RemoteOnly" >   </customErrors>   WHERE element defaultredirect represents the name of the custom error page. The mode element indicates that custom (friendly) information is displayed for users who are not running on the local Web server. 5.

ASP. NET configuration file, Web. config, explains in detail

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.