Solved

the so friendly http error?

Posted on 2000-04-19
9
236 Views
Last Modified: 2010-05-02
may be you all already notice that MSIE was so friendly to load a "user friendly html page(s)" when error occurs during browsing the selected url or files.

but it's not what i want, i like to give  my own error page(s) when my webbrowser object failed to load the selected pages, how can i do this?
0
Comment
Question by:cindafuzzy
  • 4
  • 4
9 Comments
 
LVL 1

Expert Comment

by:ollertonk
ID: 2729987
I'm using IIS4 to run our company intranet and this gives you the option to change the error pages returned to the user.  (Each is just a plain text or HTML page which can be edited).

From this I take it that the error page returned is dependant on the server that is throwing the error and the MSIE page is only displayed if the site doesn't have it's own error page. (I could be wrong about this!)

0
 
LVL 1

Expert Comment

by:derekcmartin
ID: 2730410
I am checking each page as it comes by.  I used the inet1 control.  If an error is returned, I display my own html file.  For more information, go to

http://msdn.microsoft.com/library/techart/msdn_vbhttp.htm
0
 

Author Comment

by:cindafuzzy
ID: 2733226
hi derekcmartin,

the sample from that site works fine, but what really i want is is there any way on doing this with webbrowser control event trigger, ie:

sub webbrowser1_downloadcomplete()

'do what so ever you want.. bla.. bla

sub

with pseudocode look like this

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if user clicked button x then
  set webbrowser1 to open url [http://www.experts-exchange.com]
  if webbrowser1 open failed then
     set webbrowser1 to open url [application path & error.htm]
  endif
endif
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

i hope you can get the idea?, anyway thanks
0
 

Author Comment

by:cindafuzzy
ID: 2733238
one more thing, this application is not desing run on web server only but also locally (fetch html document from harddisk), so any error customization from web server won't be the answer (ie. error page form iis)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Accepted Solution

by:
derekcmartin earned 76 total points
ID: 2734408
By what you put above, it shows that after the page is loaded from the site, it then navigates.  Here is how I did it.  This works great.  I don't have the browser navigating to the page and then checking.  I do it all before I actually load the page for the user to see.

Try this:

First add an Inet1 control to your project

Public Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)

 Inet1.Execute (URL)

end sub

Public Sub Inet1_StateChanged(ByVal State As Integer)

Dim exiterror As Error

On Error GoTo exiterror
Select Case State


    Case 11
    'This is if there was an error connecting to the host.
     False_MDI_Form.CommonDialog1.CancelError = True       False_MDI_Form.CommonDialog1.FileName = application path & error.htm
        Me.WebBrowser1.Navigate False_MDI_Form.CommonDialog1.FileName
       
        Exit Sub
       
End Select

Dim getheaderstring As String

getheaderstring = Inet1.GetChunk(100)
                'receiving 100 bytes, just enough for the header
If InStr(getheaderstring, "400") Or InStr(getheaderstring, "401") Or InStr(getheaderstring, "403") Or InStr(getheaderstring, "404") Or InStr(getheaderstring, "500") Or InStr(getheaderstring, "501") Or InStr(getheaderstring, "502") Or InStr(getheaderstring, "503") Then
                False_MDI_Form.CommonDialog1.CancelError = True
                False_MDI_Form.CommonDialog1.FileName = application path & error.htm
                Me.WebBrowser1.Navigate False_MDI_Form.CommonDialog1.FileName
                Exit Sub
End If

exiterror:
    Exit Sub
   
   
   
End Sub

0
 
LVL 1

Expert Comment

by:derekcmartin
ID: 2734413
Please omit the false_MDI_Form.  Just use whatever form you are currently on.
0
 

Author Comment

by:cindafuzzy
ID: 2735315
Adjusted points from 75 to 76
0
 

Author Comment

by:cindafuzzy
ID: 2735316
thanks for the answer derek, althought it is not what i hope for but right now it was the best i can get. anyway thanks again... you deserve the points... just plus one more for you :)
0
 
LVL 1

Expert Comment

by:derekcmartin
ID: 2735582
Thanks!  8o)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Window placement 17 77
Validating VB6 Function 19 56
Windows 10 start screen issues 9 52
Search combo error "Data Type Mismatch in Criteria Expression" 2 53
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now