Configuring for IIS 7.0 <system.webServer>

Source: Internet
Author: User

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:

    • defaultdocument   elements).

    • response compression settings (httpcompression  Element).

    • httpprotocol  section  customheaders  element).

    • module (modules  element).

    • 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
  1. 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.

  2. 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:

    < Configuration >  < system.webserver >  </ system.webserver > </ Configuration >
  3. within the system.webserver element, create a defaultdocument element.

  4. within the defaultdocument element, create a files element.

  5. 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.

    <Configuration>  <system.webserver>    <defaultdocument>      <Files>        <Addvalue= "Products.aspx" />      </Files>    </defaultdocument>  </system.webserver></Configuration>
registering a managed code module 

The managed code module is invoked each time the request is made to customize the request or response.

Configuring custom managed code Modules
  1. 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.

  2. 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:

    < Configuration >  < system.webserver >  </ system.webserver > </ Configuration >
  3. within the system.webserver element, create a modules element.

  4. 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.

    <Configuration>  <system.webserver>    <Modules>      <Addname= "CustomModule"type= "Samples.custommodule" />    </Modules>  </system.webserver></Configuration>
  5. 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.

    <Configuration>  <system.webserver>    <Modules>      <Addname= "CustomModule"type= "Samples.custommodule"Precondition= "Managedhandler" />    </Modules>    <defaultdocument>      <Files>        <Addvalue= "Products.aspx" />      </Files>    </defaultdocument>  </system.webserver></Configuration>
Configure custom Response headers with custom response headers, you can send application-specific information to your 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
    1. 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.

    2. 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:

< Configuration >  < system.webserver >  </ system.webserver > </ Configuration >
  1. within the system.webserver element, create a httpprotocol element.

  2. within the Httpprotocol element, create a customheaders element.

  3. 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.

    <Configuration>  <system.webserver>    <Httpprotocol>      <customheaders>          <Addname= "Customheader"value= "Customheader" />       <customheaders>       </Httpprotocol>  </system.webserver></Configuration>

Configuring for IIS 7.0 <system.webServer>

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.