本文介绍了HTTP GET请求和XML的答案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是新的C#中,我需要发送HTTP GET请求和读答案。我所熟悉的Java和容易可以做到这一点URLConnection类,但我不C#知道。任何人可以帮助
I am new to C#, I need to send HTTP GET request and read answer. I am familiar with Java and easy can do it URLConnection class but I don't know in c#. Can anybody help ?
推荐答案
的简单的方法是使用的:
The simplest way is to use WebClient
:
WebClient client = new WebClient();
string text = client.DownloadString(url);
(这是同步的形式;还支持异步请求)
(That's the synchronous form; it also supports asynchronous requests.)
有关更多的控制,你可能需要使用。
For more control you might want to use HttpWebRequest
.
这篇关于HTTP GET请求和XML的答案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!