Muokkaa

Jaa


<add> Element for webRequestModules (Network Settings)

Adds a custom Web request module to the application.

<configuration>
  <system.net>
    <webRequestModules>
      <add>

Syntax

<add
  prefix="URI prefix"
  type="type_fullname, assembly_fullname"
/>  

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute Description
prefix The URI prefix for requests handled by this Web request module.
type The fully qualified type name (indicated by the FullName property) and the assembly name (indicated by the FullName property), separated by a comma, that implements this Web request module.

Child Elements

None.

Parent Elements

Element Description
webRequestModules Specifies modules to use to request information from network hosts.

Remarks

The prefix attribute defines the URI prefix that uses the specified Web request module. Web request modules are typically registered to handle a specific protocol, such as HTTP or FTP, but can be registered to handle a request to a specific server or path on a server.

The Web request module is created when a URI matching prefix is passed to the WebRequest.Create method.

The value for the prefix attribute should be the leading characters of a valid URI. For example, http or http://www.contoso.com.

The value for the type attribute should be a valid type name and corresponding assembly name, separated by a comma.

Configuration Files

This element can be used in the application configuration file or the machine configuration file (Machine.config).

Example

The following example registers a custom Web request module for HTTP. You should replace the values for Version and PublicKeyToken with the correct values for the specified module.

<configuration>  
  <system.net>  
    <webRequestModules>  
      <add prefix="http"  
           type="System.Net.HttpRequestCreator, System, Version=2.0.3600.0,  
           Culture=neutral, PublicKeyToken=b77a5c561934e089"  
      />  
    </webRequestModules>  
  </system.net>  
</configuration>  

See also