Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27569

WebException & StatusCode

$
0
0
Hey,

When I do a request, sometimes the server returns a error for some reasons.

Code:

Try

Dim request As HttpWebRequest
......
......
Dim response As HttpWebResponse = request.GetResponse <= Error(WebException) When the server returns 400, 403, .... 500,...

Catch ex As WebException

'I have to handle the error code
'How can I got the status code Here ??

End Try

Usually, I use response.StatusCode, but in my case I can not use it, on error
Any Idea how to handle the error code return by the server in the catch WebException block ?

Viewing all articles
Browse latest Browse all 27569

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>