简体   繁体   English

WebRequest.Create方法是否实际调用url?

[英]Does WebRequest.Create method actually calls a url?

One of my colleague suggested me WebRequest.Create actually sends a web request to the specified url and I don't have to use asynchronous web request in order to avoid waiting. 我的一位同事建议我WebRequest.Create实际上将Web请求发送到指定的url,而不必使用异步Web请求来避免等待。

Is this true? 这是真的?

How ever I don't agree with him and when I showed him the documentation but he said that he has been calling WebRequest.Create to send requests. 我不同意他的说法,当我给他看文档时,他说他一直在打电话给WebRequest.Create来发送请求。

I'm not sure if this is true as i don't have deep knowledge of .net 我不确定这是否是正确的,因为我对.net并不了解

No, calls to GetResponse() on the created WebRequest is what actually issues the request. 不,在创建的WebRequest上对GetResponse()调用实际上是发出请求的原因。

From the docs : 文档

The GetResponse method sends a request to an Internet resource and returns a WebResponse instance. GetResponse方法将请求发送到Internet资源,并返回WebResponse实例。

That is not true. 那是不对的。 It just initializes a new request. 它只是初始化一个新请求。

You need to call GetResponse() to actually make the call. 您需要调用GetResponse()才能真正进行调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM