calling an http url from a .net console applicatio

2019-01-28 06:02发布

Is it possible to call an http url from a .net console application? can anyone give an idea.?

3条回答
Ridiculous、
2楼-- · 2019-01-28 06:18

Yes, its possible. Use the WebClient class. See a tutorial here http://www.dotnetperls.com/webclient

查看更多
forever°为你锁心
3楼-- · 2019-01-28 06:29
public string DownloadUrl(string url)
{
    return new System.Net.WebClient().DownloadString(url);
}
查看更多
再贱就再见
4楼-- · 2019-01-28 06:37

Here is a nice example if you are trying to fetch HTML from a web page using HTTP.

UPDATE: As you have posted in comment that only thing you expect in response is a string would be good to use WebClient as Chris Fulstow says in his answer.

System.Net.WebClient().DownloadString(url)
查看更多
登录 后发表回答