Loop URL

  • Thread starter Thread starter Derek Hart
  • Start date Start date
D

Derek Hart

I have a 3rd party product that is called on a server with a URL. I will
have to run thousands of these URLs in a batch.

I will do this in winforms, perhaps in a Windows Service, running on the
server. Are there dotnet commands to loop through URLs, where I can run the
URL, then wait for its response, then run the next one... in a loop. I am
just unclear on the call to run the URL, and the waiting process.
 
I may be answering my own question, but would like feedback. I have tried
this code. I am not sure if I need the oResponse variable, as I am not going
to evaluate a response. But if that is required, do I need to close the
response. Remember I just want to execute the URL... other things happen
elsewhere in the system if the URL does not work properly. So is the second
code block enough to just run through URLs? Of course each one would be
different, not www.google.com

Dim sURL As String
sURL = "http://www.google.com"
For i As Integer = 1 To 10
Dim oRequest As System.Net.HttpWebRequest =
System.Net.HttpWebRequest.Create(sURL)
oRequest.Method = System.Net.WebRequestMethods.Http.Get
Dim oResponse As System.Net.WebResponse =
oRequest.GetResponse()
oResponse.Close()
Next


Dim sURL As String
sURL = "http://www.google.com"
For i As Integer = 1 To 10
Dim oRequest As System.Net.HttpWebRequest =
System.Net.HttpWebRequest.Create(sURL)
Next
 
Back
Top