2740

C# HTTP系列1 HttpWebRequest类

系列目录     【已更新最新开发文章,点击查看详细】

  .NET Framework 中 System.Net 命名空间下提供了 HttpWebRequest 和 HttpWebResponse 2个类,他们是用于发送和接收HTTP数据的最好选择。它们支持一系列有用的属性。默认情况下这2个类对于控制台程序、WinForm、ASP.NET来说都是可访问的。HttpWebRequest 对象不是利用 new 关键字通过构造函数来创建的,而是利用工厂机制(factory mechanism),通过抽象类WebRequest.Create()方法来创建的。

HttpWebRequest webRequest = WebRequest.Create(url) as HttpWebRequest;

设置相关属性与请求参数后,接下来调用 HttpWebRequest. GetResponse 方法中通过 RequestUri 属性发出同步请求,并返回 HttpWebResponse 包含响应的对象。 

HttpWebResponse webResponse = webRequest.GetResponse() as HttpWebResponse;

可以使用 GetResponseStream 方法返回的流来接收响应的数据。 如果关闭响应对象或响应流时,剩余数据将作废。 将耗尽剩余的数据并关闭流的响应对象,如果以下条件成立时,将为后续请求重新使用套接字: 它是保持活动状态或通过管线传输请求,只有少量的数据需要接收,或在较短时间间隔内收到剩余数据。 如果没有提到条件保存或超出消耗时间,将关闭套接字。 为保持活动状态或通过管道传递的连接,我们强烈建议在应用程序直到 EOF 读取流。 这可确保将生成更好的性能和更低的使用的资源的后续请求重复使用套接字。可以把HTTP响应的数据流(Stream)绑定到一个StreamReader对象,然后就可以通过ReadToEnd()方法把整个HTTP响应作为一个字符串取回。也可以通过 StreamReader.ReadLine()方法逐行取回HTTP响应的内容。

using (StreamReader sr = new StreamReader(webResponse.GetResponseStream())) { string content = sr.ReadToEnd(); }

  当您想要将数据发送到资源时,GetRequestStream方法返回一个Stream对象以用于发送数据。该BeginGetRequestStream和EndGetRequestStream方法提供了发送数据流的异步访问。

  对于使用HttpWebRequest的客户端身份验证,客户端证书必须安装在当前用户的My certificate store中。

  该HttpWebRequest的类会引发引发WebException同时访问资源时发生错误。该WebException.Status属性包含一个WebExceptionStatus值,指示错误的来源。当WebException.Status是WebExceptionStatus.ProtocolError时,Response属性包含从资源接收的HttpWebResponse。

1 /// <summary> 2 /// HTTP请求(包含文本的body数据) 3 /// </summary> 4 /// <param name="url">请求目标URL</param> 5 /// <param name="data">主体数据(普通文本或者JSON文本)</param> 6 /// <param name="method">请求的方法。请使用 WebRequestMethods.Http 的枚举值</param> 7 /// <param name="contentType"><see langword="Content-type" /> HTTP 标头的值。请使用 ContentType 类的常量来获取</param> 8 /// <returns></returns> 9 private HttpResult Request(string url, string data, string method, string contentType) 10 { 11 HttpResult httpResult = new HttpResult(); 12 HttpWebRequest webRequest = null; 13 14 try 15 { 16 webRequest = WebRequest.Create(url) as HttpWebRequest; 17 webRequest.Method = method; 18 webRequest.Headers = HeaderCollection; 19 webRequest.CookieContainer = CookieContainer; 20 webRequest.ContentType = contentType; 21 webRequest.UserAgent = _userAgent; 22 webRequest.AllowAutoRedirect = _allowAutoRedirect; 23 webRequest.ServicePoint.Expect100Continue = false; 24 25 if (data != null) 26 { 27 webRequest.AllowWriteStreamBuffering = true; 28 using (Stream requestStream = webRequest.GetRequestStream()) 29 { 30 requestStream.Write(EncodingType.GetBytes(data), 0, data.Length); 31 requestStream.Flush(); 32 } 33 } 34 35 HttpWebResponse webResponse = webRequest.GetResponse() as HttpWebResponse; 36 if (webResponse != null) 37 { 38 GetResponse(ref httpResult, webResponse); 39 webResponse.Close(); 40 } 41 } 42 catch (WebException webException) 43 { 44 GetWebExceptionResponse(ref httpResult, webException); 45 } 46 catch (Exception ex) 47 { 48 GetExceptionResponse(ref httpResult, ex, method, contentType); 49 } 50 finally 51 { 52 if (webRequest != null) 53 { 54 webRequest.Abort(); 55 } 56 } 57 58 return httpResult; 59 } 1 /// <summary> 2 /// 获取HTTP访问网络期间发生错误时引发的异常响应信息 3 /// </summary> 4 /// <param name="httpResult">即将被HTTP请求封装函数返回的HttpResult变量</param> 5 /// <param name="webException">访问网络期间发生错误时引发的异常对象</param> 6 private void GetWebExceptionResponse(ref HttpResult httpResult, WebException webException) 7 { 8 HttpWebResponse exResponse = webException.Response as HttpWebResponse; 9 if (exResponse != null) 10 { 11 httpResult.HttpWebResponse = exResponse; 12 httpResult.Status = HttpResult.STATUS_FAIL; 13 httpResult.StatusDescription = exResponse.StatusDescription; 14 httpResult.StatusCode = (int)exResponse.StatusCode; 15 16 httpResult.RefCode = httpResult.StatusCode; 17 using (StreamReader sr = new StreamReader(exResponse.GetResponseStream(), EncodingType)) 18 { 19 httpResult.Text = sr.ReadToEnd(); 20 httpResult.RefText = httpResult.Text; 21 } 22 23 exResponse.Close(); 24 } 25 }

  HttpWebRequest公开发送到Internet资源的公共HTTP标头值作为属性,由方法设置或由系统设置; 下表包含完整列表。您可以在Headers属性中将其他标头设置为名称/值对。请注意,服务器和缓存可能会在请求期间更改或添加标头。

下表列出了由属性或方法或系统设置的HTTP标头。下表列出了由属性或方法或系统设置的HTTP标头。

<table style="height: 291px; width: 478px;"><thead><tr><th>Header</th><th>通过设置</th></tr></thead><tbody><tr><td>接受</td> <td>通过设置Accept属性。</td> </tr><tr><td>连接</td> <td>通过设置Connection属性,KeepAlive属性。</td> </tr><tr><td>内容长度</td> <td>通过设置ContentLength属性。</td> </tr><tr><td>Content-Type</td> <td>通过设置ContentType属性。</td> </tr><tr><td>期望</td> <td>通过设置Expect属性。</td> </tr><tr><td>日期</td> <td>设置当前日期到系统。</td> </tr><tr><td>Host</td> <td>设置为当前主机信息系统。</td> </tr><tr><td>If-Modified-Since</td> <td>通过设置IfModifiedSince属性。</td> </tr><tr><td>范围</td> <td>通过设置AddRange方法。</td> </tr><tr><td>引用站点</td> <td>通过设置Referer属性。</td> </tr><tr><td>Transfer-Encoding</td> <td>通过设置TransferEncoding属性 (SendChunked属性必须为true)。</td> </tr><tr><td>用户代理</td> <td>通过设置UserAgent属性。</td> </tr></tbody></table>

  本地计算机或应用程序配置文件可以指定使用默认代理。如果Proxy指定的属性,然后从代理设置Proxy属性来覆盖本地计算机或应用程序配置文件和HttpWebRequest的实例将使用指定的代理服务器设置。如果在配置文件中未指定代理且未指定Proxy属性,则HttpWebRequest类将使用从本地计算机上的Internet Explorer继承的代理设置。如果Internet Explorer中没有代理设置,则请求将直接发送到服务器。

        HttpWebRequest类继承自 Internet 资源管理器以不同的方式不是直接通过 Internet Explorer 分析跳过列表的通配符字符与分析代理跳过列表。 例如,HttpWebRequest类分析的正则表达式的"nt *"从 Internet 资源管理器的跳过列表"nt。 $"。 这不同于 Internet Explorer 的本机行为。 因此的 URL"http://intxxxxx"将绕过代理帐户使用HttpWebRequest类,但将不使用 Internet Explorer 使用代理。

<blockquote>

如果可能,框架会在创建SSL会话时对其进行缓存,并尝试将缓存会话重新用于新请求。尝试重用SSL会话时,Framework使用ClientCertificates的第一个元素(如果有),或者如果ClientCertificates为空,则尝试重用匿名会话。

</blockquote> <blockquote>

出于安全原因,默认情况下禁用cookie。如果要使用cookie,请使用CookieContainer属性启用cookie。

</blockquote>

.NET Framework 4.6 包括一个新的安全功能,将阻止不安全的密码和哈希算法的连接。 默认情况下,使用 TLS/SSL 通过 HttpClient、 HttpWebRequest、 FTPClient,SmtpClient、 SslStream 等 Api 和面向.NET Framework 4.6 的应用程序获得更安全的行为。

开发人员可能想要选择退出此行为以便保持与带 RC4 服务及其现有 SSL3 服务或 TLS 互操作性。 这篇文章介绍了如何修改你的代码,以便禁用新行为。

属性 <table class="nameValue" style="height: 2122px; width: 800px;"><tbody><tr><td>Accept</td> <td>

获取或设置 <code data-dev-comment-type="langword">Accept HTTP 标头的值。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>Address</td> <td>

获取实际响应请求的 Internet 资源的统一资源标识符 (URI)。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>AllowAutoRedirect</td> <td>

获取或设置一个值,该值指示请求是否应跟随重定向响应。

</td> </tr><tr data-moniker=" dotnet-uwp-10.0 netcore-1.0 netcore-1.1 netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>AllowReadStreamBuffering</td> <td>

获取或设置一个值,该值指示是否对从 Internet 资源接收的数据进行缓冲处理。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>AllowWriteStreamBuffering</td> <td>

获取或设置一个值,该值指示是否对发送到 Internet 资源的数据进行缓冲处理。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>AuthenticationLevel</td> <td>

获取或设置用于此请求的身份验证和模拟的级别。

(Inherited from WebRequest)</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>AutomaticDecompression</td> <td>

获取或设置所使用的解压缩类型。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>CachePolicy</td> <td>

获取或设置此请求的缓存策略。

(Inherited from WebRequest)</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>ClientCertificates</td> <td>

获取或设置与此请求关联的安全证书集合。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>Connection</td> <td>

获取或设置 <code data-dev-comment-type="langword">Connection HTTP 标头的值。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>ConnectionGroupName</td> <td>

获取或设置请求的连接组的名称。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>ContentLength</td> <td>

获取或设置 <code data-dev-comment-type="langword">Content-length HTTP 标头。

</td> </tr><tr><td>ContentType</td> <td>

获取或设置 <code data-dev-comment-type="langword">Content-type HTTP 标头的值。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>ContinueDelegate</td> <td>

获取或设置当从 Internet 资源接收到 HTTP 100-continue 响应时调用的委托方法。

</td> </tr><tr data-moniker=" dotnet-uwp-10.0 netcore-1.0 netcore-1.1 netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>ContinueTimeout</td> <td>

获取或设置在接收到来自服务器的 100-Continue 之前要等待的超时(以毫秒为单位)。

</td> </tr><tr><td>CookieContainer</td> <td>

获取或设置与此请求关联的 Cookie。

</td> </tr><tr data-moniker=" netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>CreatorInstance</td> <td>

当在子类中重写时,获取从 IWebRequestCreate 类派生的工厂对象,该类用于创建为生成对指定 URI 的请求而实例化的 WebRequest。

(Inherited from WebRequest)</td> </tr><tr><td>Credentials</td> <td>

获取或设置请求的身份验证信息。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>Date</td> <td>

获取或设置要在 HTTP 请求中使用的 <code data-dev-comment-type="langword">Date HTTP 标头值。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinmac-3.0 "><td>DefaultCachePolicy</td> <td>

获取或设置此请求的默认缓存策略。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>DefaultMaximumErrorResponseLength</td> <td>

获取或设置 HTTP 错误响应的默认最大长度。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>DefaultMaximumResponseHeadersLength</td> <td>

获取或设置 MaximumResponseHeadersLength 属性的默认值。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>Expect</td> <td>

获取或设置 <code data-dev-comment-type="langword">Expect HTTP 标头的值。

</td> </tr><tr><td>HaveResponse</td> <td>

获取一个值,该值指示是否收到了来自 Internet 资源的响应。

</td> </tr><tr><td>Headers</td> <td>

指定构成 HTTP 标头的名称/值对的集合。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>Host</td> <td>

获取或设置要在 HTTP 请求中独立于请求 URI 使用的 Host 标头值。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>IfModifiedSince</td> <td>

获取或设置 <code data-dev-comment-type="langword">If-Modified-Since HTTP 标头的值。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>ImpersonationLevel</td> <td>

获取或设置当前请求的模拟级别。

(Inherited from WebRequest)</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>KeepAlive</td> <td>

获取或设置一个值,该值指示是否与 Internet 资源建立持久性连接。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>MaximumAutomaticRedirections</td> <td>

获取或设置请求将跟随的重定向的最大数目。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>MaximumResponseHeadersLength</td> <td>

获取或设置响应标头允许的最大长度。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>MediaType</td> <td>

获取或设置请求的媒体类型。

</td> </tr><tr><td>Method</td> <td>

获取或设置请求的方法。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>Pipelined</td> <td>

获取或设置一个值,该值指示是否通过管线将请求传输到 Internet 资源。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>PreAuthenticate</td> <td>

获取或设置一个值,该值指示是否随请求发送一个身份验证标头。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>ProtocolVersion</td> <td>

获取或设置用于请求的 HTTP 版本。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>Proxy</td> <td>

获取或设置请求的代理信息。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>ReadWriteTimeout</td> <td>

获取或设置写入或读取流时的超时(以毫秒为单位)。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>Referer</td> <td>

获取或设置 <code data-dev-comment-type="langword">Referer HTTP 标头的值。

</td> </tr><tr><td>RequestUri</td> <td>

获取请求的原始统一资源标识符 (URI)。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>SendChunked</td> <td>

获取或设置一个值,该值指示是否将数据分段发送到 Internet 资源。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>ServerCertificateValidationCallback</td> <td>

获取或设置用于验证服务器证书的回调函数。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>ServicePoint</td> <td>

获取用于请求的服务点。

</td> </tr><tr data-moniker=" dotnet-uwp-10.0 netcore-1.0 netcore-1.1 netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>SupportsCookieContainer</td> <td>

获取一个值,该值指示请求是否为 CookieContainer 提供支持。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>Timeout</td> <td>

获取或设置 GetResponse() 和 GetRequestStream() 方法的超时值(以毫秒为单位)。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>TransferEncoding</td> <td>

获取或设置 <code data-dev-comment-type="langword">Transfer-encoding HTTP 标头的值。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>UnsafeAuthenticatedConnectionSharing</td> <td>

获取或设置一个值,该值指示是否允许经过高速 NTLM 身份验证的连接共享。

</td> </tr><tr data-moniker=" dotnet-uwp-10.0 netcore-1.0 netcore-1.1 netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>UseDefaultCredentials</td> <td>

获取或设置一个 Boolean 值,该值控制默认凭据是否随请求一起发送。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>UserAgent</td> <td>

获取或设置 <code data-dev-comment-type="langword">User-agent HTTP 标头的值。

</td> </tr></tbody></table>   方法 <table class="nameValue" style="height: 1336px; width: 800px;"><tbody><tr><td>Abort()</td> <td>

取消对 Internet 资源的请求。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>AddRange(Int32)</td> <td>

向请求添加从请求数据的开始处或结束处的特定范围的字节范围标头。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>AddRange(Int32, Int32)</td> <td>

向请求添加指定范围的字节范围标头。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>AddRange(Int64)</td> <td>

向请求添加从请求数据的开始处或结束处的特定范围的字节范围标头。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>AddRange(Int64, Int64)</td> <td>

向请求添加指定范围的字节范围标头。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>AddRange(String, Int32)</td> <td>

向请求添加从请求数据的开始处或结束处计算的特定范围的 Range 标头。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>AddRange(String, Int32, Int32)</td> <td>

向请求添加指定范围的范围标头。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>AddRange(String, Int64)</td> <td>

向请求添加从请求数据的开始处或结束处计算的特定范围的 Range 标头。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>AddRange(String, Int64, Int64)</td> <td>

向请求添加指定范围的范围标头。

</td> </tr><tr><td>BeginGetRequestStream(AsyncCallback, Object)</td> <td>

开始对用于写入数据的 Stream 对象执行异步请求。

</td> </tr><tr><td>BeginGetResponse(AsyncCallback, Object)</td> <td>

开始对 Internet 资源的异步请求。

</td> </tr><tr data-moniker=" netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>CreateObjRef(Type)</td> <td>

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。

(Inherited from MarshalByRefObject)</td> </tr><tr><td>EndGetRequestStream(IAsyncResult)</td> <td>

结束对用于写入数据的 Stream 对象的异步请求。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>EndGetRequestStream(IAsyncResult, TransportContext)</td> <td>

结束对用于写入数据的 Stream 对象的异步请求,并输出与该流关联的 TransportContext。

</td> </tr><tr><td>EndGetResponse(IAsyncResult)</td> <td>

结束对 Internet 资源的异步请求。

</td> </tr><tr data-moniker=" dotnet-uwp-10.0 netcore-1.0 netcore-1.1 netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-1.0 netstandard-1.1 netstandard-1.2 netstandard-1.3 netstandard-1.4 netstandard-1.5 netstandard-1.6 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>Equals(Object)</td> <td>

确定指定的对象是否等于当前对象。

(Inherited from Object)</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>GetLifetimeService()</td> <td>

检索控制此实例的生存期策略的当前生存期服务对象。

(Inherited from MarshalByRefObject)</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>GetObjectData(SerializationInfo, StreamingContext)</td> <td>

使用序列化目标对象所需的数据填充 SerializationInfo。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>GetRequestStream()</td> <td>

获取用于写入请求数据的 Stream 对象。

</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>GetRequestStream(TransportContext)</td> <td>

获取用于写入请求数据的 Stream 对象,并输出与该流关联的 TransportContext。

</td> </tr><tr data-moniker=" dotnet-uwp-10.0 netcore-1.0 netcore-1.1 netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>GetRequestStreamAsync()</td> <td>

当在子类中被重写时,将用于写入数据的 Stream 作为异步操作返回到 Internet 资源。

(Inherited from WebRequest)</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>GetResponse()</td> <td>

返回来自 Internet 资源的响应。

</td> </tr><tr data-moniker=" dotnet-uwp-10.0 netcore-1.0 netcore-1.1 netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>GetResponseAsync()</td> <td>

当在子类中被重写时,将作为异步操作返回对 Internet 请求的响应。

(Inherited from WebRequest)</td> </tr><tr data-moniker=" dotnet-uwp-10.0 netcore-1.0 netcore-1.1 netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-1.0 netstandard-1.1 netstandard-1.2 netstandard-1.3 netstandard-1.4 netstandard-1.5 netstandard-1.6 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>GetType()</td> <td>

获取当前实例的 Type。

(Inherited from Object)</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>InitializeLifetimeService()</td> <td>

获取生存期服务对象来控制此实例的生存期策略。

(Inherited from MarshalByRefObject)</td> </tr><tr data-moniker=" dotnet-uwp-10.0 netcore-1.0 netcore-1.1 netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-1.0 netstandard-1.1 netstandard-1.2 netstandard-1.3 netstandard-1.4 netstandard-1.5 netstandard-1.6 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>MemberwiseClone()</td> <td>

创建当前 Object 的浅表副本。

(Inherited from Object)</td> </tr><tr data-moniker=" netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>MemberwiseClone(Boolean)</td> <td>

创建当前 MarshalByRefObject 对象的浅表副本。

(Inherited from MarshalByRefObject)</td> </tr><tr data-moniker=" dotnet-uwp-10.0 netcore-1.0 netcore-1.1 netcore-2.0 netcore-2.1 netcore-2.2 netcore-3.0 netframework-1.1 netframework-2.0 netframework-3.0 netframework-3.5 netframework-4.0 netframework-4.5 netframework-4.5.1 netframework-4.5.2 netframework-4.6 netframework-4.6.1 netframework-4.6.2 netframework-4.7 netframework-4.7.1 netframework-4.7.2 netframework-4.8 netstandard-1.0 netstandard-1.1 netstandard-1.2 netstandard-1.3 netstandard-1.4 netstandard-1.5 netstandard-1.6 netstandard-2.0 netstandard-2.1 xamarinandroid-7.1 xamarinios-10.8 xamarinmac-3.0 "><td>ToString()</td> <td>

返回表示当前对象的字符串。

(Inherited from Object)</td> </tr></tbody></table>   安全性 WebPermission <br data-filtered="filtered" />若要访问请求的 URI 或请求重定向到任何 URI。 关联的枚举: Connect   系列目录     【已更新最新开发文章,点击查看详细】

来源:博客园

作者:张传宁

链接:https://www.cnblogs.com/SavionZhang/p/11392709.html

Recommend