调用一个URL - C# [英] Invoking a URL - c#

查看:302
本文介绍了调用一个URL - C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为尝试调用在C#中的网址,我在调用只是有兴趣,并且不关心响应。当我有以下的,这是否意味着我米调用网址是什么?

  HttpWebRequest的要求=(HttpWebRequest的)WebRequest.Create(URL);
 

解决方案

您需要实际执行的请求:

  VAR请求=(HttpWebRequest的)WebRequest.Create(URL);
request.GetResponse();
 

要的GetResponse的调用使到服务器的出站呼叫。您可以丢弃该响应,如果你不关心它。

I m trying to invoke a URL in C#, I am just interested in invoking, and dont care about response. When i have the following, does it mean that I m invoking the URL?

 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

解决方案

You need to actually perform the request:

var request = (HttpWebRequest)WebRequest.Create(url);
request.GetResponse();

The call to GetResponse makes the outbound call to the server. You can discard the response if you don't care about it.

这篇关于调用一个URL - C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆