How to detecting a redirect or a 404 status

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I am trying to figure whether a page exist in the server or not without
parsing the document for a 404 or a for a "error". I am using the webbrower
control. Does that return a status code of some sort to indicate if a page
did indeed exist?

Any suggestions?

Many thanks
Shahriar
 
If you navigate to a page that does not exist, then you can create a handler
for the NavigateError event that receives a parameter of type
DWebBrowserEvents2_NavigateErrorEvent.

If you look at this parameter's statuscode property, you will find that it
has a value of 404 if the requested page is not found on the server.

HTH.

-Eric
 
In the DocumentComplete event handler, you can check that the value of the
url property of the DWebBrowserEvents2_DocumentCompleteEvent parameter is the
same as the url you initially requested. That is the only way that I can
think of to check to see if the server has redirected you to a different url
as part of your request.

Hope this is what you were looking for.

Regards,

-Eric
 
Hi Eric -
Thanks for your replies.

I have tried the following error handler.
Private Sub WebBrowser1_NavigateError(ByVal pDisp As Object, ByVal URL As
Object, ByVal Frame As Object, ByVal StatusCode As Object, ByVal Cancel As
Boolean)

MsgBox("in error")

End Sub

However, when I try to navigate to page that does not exist, the error
handler doesnt execute. Can you give me a little sample? Also, why does
the webbrowser not have the navigate2 method, I only see navigate.



Thanks
 
Back
Top