WebBrowser Refreshing Problem  
Author Message
joynerCN





PostPosted: Visual Basic Language, WebBrowser Refreshing Problem Top

I've got a WebBrowser control in my current program that, every minute and a half, loads a web page and parses some string information out of it.

The problem is, after running for a while, it stops reloading the page; everytime it 'loads' the page, it loads the exact same contact the page had the last time it was loaded, although the actual page content has changed.

Viewing the page in IE outside the program, I can see visually that the site really has changed; but the program continues only to see an older version of the page.

Why is this happening, and how can it be fixed

Note: the problem persists when I log on/off the computer, and when I restart the computer entirely. It doesn't happen for all pages being dealt with in this program, nor does it happen right away; but once a page stops refreshing, it never starts again.



Visual Basic1  
 
 
ahmedilyas





PostPosted: Visual Basic Language, WebBrowser Refreshing Problem Top

have you tried to use the Refresh command

Me.theWebBrowserControl.Refresh(WebBrowserRefreshOption.Completely)

what happens now :-)



 
 
joynerCN





PostPosted: Visual Basic Language, WebBrowser Refreshing Problem Top

Trying that - but does Refreshing not throw a DocumentCompleted event Because I can see the frame getting refreshed I think, but the code in the DocumentCompleted event isn't being executed.

And, if that's the case, how can I trigger a DocumentCompleted-style event when the page is Refreshed (I'm parsing information out of these pages, and thus I need the DocumentCompleted event to wait for the page to load to parse it).


 
 
ahmedilyas





PostPosted: Visual Basic Language, WebBrowser Refreshing Problem Top

the document complete event will only be fired when the webbrowser has navigated to a page :-)

even though this is probably going a different way and out of scope but have you tried this:

  • delete the temp internet files and history on your computer

  • tried using the WebClient class to read the stream of data from the website then setting the DocumentStream property of the webbrowser control to the stream of data recieved via the webclient class I know this is a bit off but it would help tackle the problem a bit more. An example:

    1)

    Dim theRequest as System.Net.WebRequest = System.Net.WebRequest.Create("urlHere")

    Dim theResponse as System.Net.WebResponse = CType(theRequest.GetResponse, HttpWebResponse)

    Me.theWebBrowserControl.DocumentStream = theResponse.GetResponseStream()

    2)

    Dim wc as new System.Net.WebClient()

    Me.theWebBrowser.DocumentText = wc.DownloadString("urlHere")



  •  
     
    joynerCN





    PostPosted: Visual Basic Language, WebBrowser Refreshing Problem Top

    I'd rather at least try and follow the same method I've been using if at all possible - that's a major overhaul for a relatively small problem.

    Does Refreshing throw any event at all on its completion


     
     
    ahmedilyas





    PostPosted: Visual Basic Language, WebBrowser Refreshing Problem Top

    im not sure but this is what the docs state:

    A document refresh simply reloads the current page, so the Navigating, Navigated, and DocumentCompleted events do not occur when you call the Refresh method.

    doing method 1 of the 2nd suggestion seems to work fine for me, but for you to test now ;-) (it does throw the document_completed event)



     
     
    joynerCN





    PostPosted: Visual Basic Language, WebBrowser Refreshing Problem Top

    You mean your second suggestion That would just go exactly in place of where I currently have the Navigate() or Refresh() method, correct And it definitely reloads the page directly from the server every time
     
     
    ahmedilyas





    PostPosted: Visual Basic Language, WebBrowser Refreshing Problem Top

    that is correct my friend :-)

     
     
    joynerCN





    PostPosted: Visual Basic Language, WebBrowser Refreshing Problem Top

    Alright, now hitting a weird problem.

    I'm doing this for each of 5 web sites, in 5 separate Browser controls. That code works for the first two browser, but freezes on the third one.

    But, if I comment out the first two, it then works on the second two, and then freezes on the last one. So it's as if it works on only 2 controls no matter what. Huh What's going on here

    Also, the second one loads a bit slower than the first one.

    Good news is when I comment out all but two of them, everything else appears to work - granted I can't reproduce the not-refreshing problem anyway, but at least this way appears to work as well as the old way.


     
     
    joynerCN





    PostPosted: Visual Basic Language, WebBrowser Refreshing Problem Top

    Actually, clearing my temp files worked just fine.

    Which brings up another question - how can I revert to an old version of my code I'm still running the version installed from before all these changes, is there a way to revert back to the code that led to that last installation


     
     
    ahmedilyas





    PostPosted: Visual Basic Language, WebBrowser Refreshing Problem Top

    haha! :-) good question, im not sure to be honest - not unless you have made backup copies, or perhaps having an older exe version if you have an older exe version you can use a .NET Reflector to view the code of that exe then simply perhaps copy and paste it into a new file and use that code and built on it

     
     
    joynerCN





    PostPosted: Visual Basic Language, WebBrowser Refreshing Problem Top

    Where might I find a .NET reflector
     
     
    ahmedilyas





    PostPosted: Visual Basic Language, WebBrowser Refreshing Problem Top

    http://www.aisto.com/roeder/dotnet/

     
     
    joynerCN





    PostPosted: Visual Basic Language, WebBrowser Refreshing Problem Top

    Pardon my stupidity, but I'm not sure if I have what I need to use that. I've got all the builds from when I 'Published' my project, and I'd like to revert back to build 1.0.0.13 (rather than the latest, which is .14). I'm running .13, but where might I find the file to use the reflector on
     
     
    ahmedilyas





    PostPosted: Visual Basic Language, WebBrowser Refreshing Problem Top

    im not sure to be honest since I have never used publishing before, tried finding the filename of it on your computer then performing the reflection on it