Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invoking a URL - c#

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);
like image 835
DarthVader Avatar asked Apr 30 '10 13:04

DarthVader


2 Answers

You can use this:

string address = "http://www.yoursite.com/page.aspx";
using (WebClient client = new WebClient())
{
    client.DownloadString(address);
}
like image 164
Xstahef Avatar answered Oct 22 '22 06:10

Xstahef


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.

like image 21
John Källén Avatar answered Oct 22 '22 07:10

John Källén