Search code examples
c#.nethttpwebrequestrequest

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);

Solution

  • 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.