Terry said:
I found that it's hanging up at the following line of code:
Dim wres As HttpWebResponse = wreq.GetResponse
I put a messagebox before and after this line. I get the before, but
not the after.
Did you wait to see if you get a an error of WebExceptionStatus.Timeout or
something else?
Does anything appear in the logs of the server you're querying?
You need to put all web requests in try...catch blocks, for example with a
POST request you might do something like this:-
Private Function doSearch(ByVal myUrl As String, ByVal params As String) As
String
Dim wReq As System.Net.HttpWebRequest = CType(WebRequest.Create(myUrl),
HttpWebRequest)
Dim wResp As WebResponse
Dim wRespStream As Stream
Dim fail As Boolean = False
Dim result As StringBuilder = New StringBuilder
With wReq
.Method = "POST"
.ContentType = "application/x-www-form-urlencoded"
.ContentLength = Len(params)
.KeepAlive = False
' give it 60000ms to respond
.Timeout = 60000
End With
Dim myWriter As New StreamWriter(wReq.GetRequestStream())
Try
myWriter.Write(params)
Catch e As Exception
fail = True
With result
.Append("<p>Failed to initiate search request. Please try again in a
few moments.</p>")
.Append("<p>If the problem persists, please contact the IT
Helpdesk.</p>")
End With
Finally
myWriter.Close()
End Try
Try
wResp = wReq.GetResponse()
Catch objEx As Exception
fail = True
If objEx.Equals(WebExceptionStatus.Timeout) Then
result.Append("<p>Request timed out.</p>")
End If
With result
.Append("<p>Communication failure: " & objEx.Message & "</p><p>Please
close your browser and try again in a few minutes.</p>")
.Append("<p>If the problem persists, please contact the IT
Helpdesk.</p>")
End With
End Try
If Not (fail) Then
Try
wRespStream = wResp.GetResponseStream()
Catch
fail = True
With result
.Append("<p>No response to search request. Please try again in a few
moments.<p>")
.Append("<p>If the problem persists, please contact the IT
Helpdesk.</p>")
End With
End Try
If Not (fail) Then
Dim reader As New StreamReader(wRespStream, Encoding.ASCII)
result.Append(reader.ReadToEnd())
reader.Close()
wRespStream.Close()
End If
End If
Return result.ToString
End Function 'doSearch
(I'm sure there's something iffy with the logic somewhere in there, but it
works well enough
Andrew