Partager via


<add> Element for webRequestModules (Network Settings) 

Adds a custom Web request module to the application.

<add 
  prefix = "URI prefix" 
  type = "module name, Version, Culture, PublicKeyToken" 
/>

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 assembly and class name of the module 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 UR --for example, "http", or "https://www.contoso.com".

The value for the type attribute should be a valid DLL name and corresponding class 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 code 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

Reference

Network Settings Schema
WebRequest