To configure ASP. NET

Source: Internet
Author: User

Web. config is an XML text file used to store ASP. NET Web application configuration information, such as the most common configuration ASP. NET Web application authentication method), which 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: <processModel> exception 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.

Web. config configuration file default configuration settings) All the following code should be located in

<Configuration>
<System. web>
And
</System. web>
</Configuration>

For the purpose of learning, the following examples omit this XML tag.

1. <authentication> section

Purpose: Configure ASP. NET authentication to support Windows, Forms, PassPort, and 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 authentication based on form Forms. When a user who does not log on to the website that requires authentication, the webpage automatically jumps to the login webpage.

 
 
  1. <authentication mode="Forms" >  
  2. <forms loginUrl="logon.aspx" name=".FormsAuthCookie"/>  
  3. </authentication> 

The element loginUrl indicates the name of the login webpage, and name indicates the Cookie name.

2. <authorization> section

Purpose: control access to URL resources from clients. For example, Anonymous Users are allowed to access URL resources ). This element can be declared on any level of computer, site, application, subdirectory or page. Must be used with the <authentication> section.

Example: The following example disables access by anonymous users:

 
 
  1. <authorization>  
  2. <deny users="?"/>  
  3. </authorization> 


Note: You can use user. identity. name to obtain the user name that has been verified. You can use
The web. Security. FormsAuthentication. RedirectFromLoginPage method redirects authenticated users to the page the user just requested. For specific examples, see: Forms verification http://www.fanvb.net/websample/dataauth.aspx

3. <compilation> section

Purpose: configure all compilation settings used by ASP. NET. The default debug attribute is "True". After the program is compiled and delivered, it should be set to the TrueWeb. config file for detailed instructions. The example is omitted here)

  1. SQL statements in ASP. NET
  2. Use StringBuilder in ASP. NET
  3. Response. Write in ASP. NET
  4. Analysis on ASP. NET authorization Module
  5. Processing Process for ASP. NET Runtime

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.