如何:检索与 WebRequest 匹配的特定于协议的 WebResponseHow to: Retrieve a Protocol-Specific WebResponse that Matches a WebRequest

此示例演示如何检索与 WebRequest 匹配的特定于协议的 WebResponse。This example shows how to retrieve a protocol-specific WebResponse that matches a WebRequest.

示例Example

WebRequest req = WebRequest.Create("http://www.contoso.com/");  
WebResponse resp = req.GetResponse();  
Dim req As WebRequest = WebRequest.Create("http://www.contoso.com")  
Dim resp As WebResponse = req.GetResponse()  

编译代码Compiling the Code

此示例需要:This example requires:

  • 引用 System.Net 命名空间 。References to the System.Net namespace.

请参阅See also