<webRequestModules > 元素(网络设置)<webRequestModules> Element (Network Settings)

指定用于从网络主机请求信息的模块。Specifies modules to use to request information from network hosts.

<configuration> <configuration>
  @ no__t <system >   <system.net>
  @ no__t-1 @ no__t-2 @ no__t @ no__t-4webRequestModules >    <webRequestModules>

语法Syntax

<webRequestModules>   
</webRequestModules>  

特性和元素Attributes and Elements

下列各节描述了特性、子元素和父元素。The following sections describe attributes, child elements, and parent elements.

特性Attributes

无。None.

子元素Child Elements

元素Element 说明Description
addadd 向应用程序添加自定义 Web 请求模块。Adds a custom Web request module to the application.
clearclear 从应用程序中删除所有已注册的 Web 请求模块。Removes all registered Web request modules from the application.
removeremove 从应用程序中移除自定义 Web 请求模块。Removes a custom Web request module from the application.

父元素Parent Elements

元素Element 说明Description
system.netsystem.net 包含指定 .NET Framework 如何连接到网络的设置。Contains settings that specify how the .NET Framework connects to the network.

备注Remarks

webRequestModules 元素注册 WebRequest 类的子代,以处理向网络主机发出的信息请求。The webRequestModules element registers descendants of the WebRequest class to handle information requests to network hosts. Web 请求模块必须实现 IWebRequestCreate 接口。Web request modules must implement the IWebRequestCreate interface.

.NET Framework 包含以 http://https://file:// 开头的 Uri 的 Web 请求模块。The .NET Framework includes Web request modules for URIs that begin with http://, https://, and file://. 只能通过在配置文件中注册自定义模块来重写默认模块。You can override the default modules only by registering a custom module in the configuration file.

配置文件Configuration Files

此元素可在应用程序配置文件或计算机配置文件 (Machine.config) 中使用。This element can be used in the application configuration file or the machine configuration file (Machine.config).

示例Example

下面的示例将注册默认的 HTTP 模块。The following example registers the default HTTP module. 应将版本和 PublicKeyToken 的值替换为指定模块的正确值。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