Understanding Web.config Documents

Source: Internet
Author: User
I. Understanding of Web.config Documents

The Web.config file is an XML text file that stores configuration information for ASP.net Web applications (such as the most common settings asp.net the way the Web application is authenticated) and can appear in every directory in the application. When you create a new Web application via vb.net, a default is automatically created in the root directory by default
Web.config files, including the default configuration settings, all subdirectories inherit its configuration settings. If you want to modify the configuration settings for subdirectories, you can create a new Web.config file in the subdirectory. It can provide configuration information in addition to 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 require a restart of the service to take effect (note the exception to the:<processmodel> section). Of course, Web.config files can be extended. You can customize the new configuration parameters and write configuration section handlers to process them.

Ii. web.config configuration file (default configuration settings) All of the following code should be located in the

<configuration>
<system.web>

And

</system.web>
</configuration>

, for learning purposes The following example omits this XML tag

1, <authentication> Festival

Role: Configure ASP.net authentication support (for Windows, Forms, PassPort, none four). This element can only be declared at the computer, site, or application level. <authentication> elements must be used in conjunction with the <authorization> section.

Example:

The following example configures the site for forms-based authentication, and the page automatically jumps to the landing page when no logged user accesses the page that requires authentication.

<authentication mode= "Forms" >
<forms loginurl= "logon.aspx" name= ". Formsauthcookie "/>

</authentication>

where element loginurl represents the name of the landing page, name means the cookie name

2, <authorization> Festival

Role: Controls client access to URL resources (such as allowing anonymous users to 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 prohibits access for anonymous users

<authorization>
<deny users= "?" />
</authorization>

Note: You can use User.Identity.Name to get the current user name that has been validated;
Web. The Security.FormsAuthentication.RedirectFromLoginPage method redirects the authenticated user to the page that the user has just requested. For specific examples please refer to:

Forms Validation Http://www.fanvb.net/websample/dataauth.aspx

3, <compilation> Festival

Role: Configure all compilation settings used by asp.net. The default Debug property is "true". You should set it to True after the program compilation has been delivered and used (in the Web.config file for detailed instructions, omit the example)

4, <customErrors>

Role: Provides information about custom error messages for ASP.net applications. It does not apply to errors that occur in XML Web services.

Example: When an error occurs, the page is jumped to a 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.

Total 3 page: previous 1 [2] [3] Next page



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.