开发者

trap error in httpwebresponse

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜