views:

51

answers:

2

I am using webclient class to post some data to a web form. I would like to get the response status code of the form submission. So far I've found out how to get the status code if there is a exception

Catch wex As WebException
        If TypeOf wex.Response Is HttpWebResponse Then
          msgbox(DirectCast(wex.Response, HttpWebResponse).StatusCode)
            End If

However if the form is submitted successfully and no exception is thrown then I won't know the status code(200,301,302,...)

Is there some way to get the status code when there is no exceptions thrown?

PS: I prefer not to use httpwebrequest/httpwebresponse

+1  A: 
kbrimington
it seems that the only way would be webrequest/response
julio
A: 

You should be able to use the "client.ResponseHeaders[..]" call, see this link for examples of getting stuff back from the response

Paul Hadfield
the response headers returned are the server headers like server,date,pragma,etc. but no status code(200,301,404...)
julio
Sorry about that, was a bit surprised to find that wasn't returned.
Paul Hadfield