I have a httpwebrequest where a post data that goes into a freeze waiting for a response. I want to have this timeout so I can continue looping and ignore the error.
request.Method = "POST"
request.ContentLength = data.Length
request.ContentType = "application/xml; charset=utf-8"
request.Timeout = 20000
....
**Using oResponse As HttpWebResponse = request.GetResponse()**
Dim reader As New StreamReader(oResponse.GetResponseStream())
开发者_开发百科 responseData = reader.ReadToEnd()
reader.Dispose()
oResponse.Close()
End Using
Have a look at the HttpWebRequest.Timeout Property.
With this you can get or set the time-out value in milliseconds for the GetResponse and GetRequestStream methods.
精彩评论