calling an http url from a .net console applicatio

2019-01-28 06:36发布

问题:

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

回答1:

public string DownloadUrl(string url)
{
    return new System.Net.WebClient().DownloadString(url);
}


回答2:

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)


回答3:

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