Cross-domain Learning note 3--web.config Settings system.webserver details, setting the default document for the site

Source: Internet
Author: User

I do not understand, in this first recorded, left to learn later ...

How to: Configure <system.webServer> section 2008-06-14 for IIS 7.0 22:26http://technet.microsoft.com/zh-cn/sysinternals/bb763179.aspx

How to: Configure <system.webServer> sections for IIS 7.0
The system.webserver section in the Web. config file specifies the IIS 7.0 settings that apply to the WEB application. System. WebServer is a child of the configuration section. For more information, see IIS 7.0:system.webserver section group (IIS Settings Schema) (IIS 7.0:system.webserver stanza groups (IIS provisioning Schema)).

The following are available on the system. Example of Web server settings that are made in the WebServer configuration group:

When a request does not contain a specific resource, the WEB server returns the default document (defaultdocument element) to the client.

The compression setting for the response (httpcompression element).

The custom header (the customheaders element of the Httpprotocol section).

Module (modules Element).

The handler (handlers Element).

Some of the settings in the System.webserver section apply only to IIS 7 Integrated mode, not to Classic mode. Specifically, if the application is running in Classic mode, the system of the Web. config file is ignored. All managed code modules and handlers specified in the WebServer section. As with earlier versions of IIS, managed code modules and handlers must be defined in the httpmodules and httphandlers elements of the system.web section.

This topic illustrates the three common configuration tasks that you need to modify the system.webserver section:

Add a default file so that when the request URL does not contain a specific file, the default file is provided.

Registers a managed code module.

Add a custom response header.
Configure default files when the request URL does not contain a specific file for the Web application, IIS 7.0 provides a default file.

Configure Default Files
If your application does not have a Web. config file, use Visual Studio or a text editor to create the file.

For more information, see Editing an ASP. NET configuration file.

If the Web. config file does not already contain the system.webserver section, create the section in the configuration element, as shown in the following example:

Copy Code
<configuration>
<system.webServer>
</system.webServer>
</configuration>

Within the system.webserver element, create a defaultdocument element.

Within the defaultdocument element, create a files element.

Create an add element within the files element and specify the path and name of the default file within the Value property.

The following example shows a system.webserver section that is configured to provide a products.aspx file as the default file.

Copy Code
<configuration>
<system.webServer>
<defaultDocument>
<files>
<add value= "Products.aspx"/>
</files>
</defaultDocument>
</system.webServer>
</configuration>

Registering a managed code module invokes a managed code module each time a request is made to customize the request or response.

Configuring custom managed code Modules
If your application does not have a Web. config file, use Visual Studio or a text editor to create the file.

For more information, see Editing an ASP. NET configuration file.

If the Web. config file does not already contain the system.webserver section, create the section in the configuration element, as shown in the following example:

Copy Code
<configuration>
<system.webServer>
</system.webServer>
</configuration>

Within the system.webserver element, create a modules element.

Create an add element within the modules element and specify the custom module in the name and type properties.

The actual name and type depend on the module you are adding. The following example shows how to add a custom module named CustomModule, which will be implemented as type Samples.custommodule.

Copy Code
<configuration>
<system.webServer>
<modules>
<add name= "CustomModule" type= "Samples.custommodule"/>
</modules>
</system.webServer>
</configuration>

Add the Precondition property to the module registration and set its value to Managedhandler.

A preceding condition causes the module to be called only when an ASP. NET application resource, such as an. aspx file or managed handler, is requested. Static files, such as. htm files, are not included in the resource.

Its configuration section will resemble the following example.

Copy Code
<configuration>
<system.webServer>
<modules>
<add name= "CustomModule" type= "Samples.custommodule"
precondition= "Managedhandler"/>
</modules>
<defaultDocument>
<files>
<add value= "Products.aspx"/>
</files>
</defaultDocument>
</system.webServer>
</configuration>

Configure custom response headers The custom response header is used to send application-specific information to the browser. For example, you can add a content-language header to describe the language used in the body of the Web page. To do this, provide one or more language and country/region values, such as en-us (U.S. English) or EN-GB (UK English).

Configure Custom Response Headers
If your application does not have a Web. config file, use Visual Studio or a text editor to create the file.

For more information, see Editing an ASP. NET configuration file.

If the Web. config file does not already contain the system.webserver section, create the section in the configuration element, as shown in the following example:

Copy Code
<configuration>
<system.webServer>
</system.webServer>
</configuration>

Within the system.webserver element, create a HTTPPROTOCOL element.

Within the Httpprotocol element, create a customheaders element.

Create an add tag within the customheaders element and specify a custom header in the name and Value properties.

The actual name and type will depend on the functionality of the header in the application. The following example shows how to add a custom header named Customheader with a value of Customheader.

Copy Code
<configuration>
<system.webServer>
<customHeaders>
<add name= "Customheader" value= "Customheader"/>
<customHeaders>
</system.webServer>

</configuration>

[This log by Simon in 2011-06-12 09:20 AM edit]
Article from: the original site

Original link: http://blog.csdn.net/happymagic/article/details/6733232

Cross-Domain Learning notes 3--web.config settings system.webserver details, setting default documents for the site

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.