6 Replies - 973 Views - Last Post: 24 January 2013 - 04:35 PM Rate Topic: -----

#1 LilGhost  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 98
  • Joined: 12-October 12

Webbrowser.Navigating Skips

Posted 24 January 2013 - 08:36 AM

Hey, so i'm working on an application that use a webbrowser to access a link. Now, this first link it accesses (we'll call it URL.com/process1.php) redirects to the second link (we'll call this one URL.com/process2.php). So between process1 & process2 we want to pause the navigation, do some stuff and then resume the navigation. The idea seems simple enough using something like this:
Sub web1_docCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgsHandles Webbrowser1.DocumentCompleted
If WebBrowser1.Url.ToString.Contains("process1.php") Then
WebBrowser1.AllowNavigation = False
DoStuff()
End If
End Sub

Sub DoStuff()
' Stuff to do here
WebBrowser1.AllowNavigation = True
WebBrowser1.Navigate(URL.com/process2.php)
End Sub



The problem comes with the fact that when we access process1.php, the webbrowser never accesses the "DocumentCompleted" handler. Because of this, I'm not able to throw the "DoStuff()" command in between these redirects and stall them. If anyone has some ideas, or a way to do this let me know, thanks. I traced it out with fiddler under normal circumstances and it shows it Posting to process1 and then Getting from process2. Which is right, i just need to know how i can make sure webbrowser1.documentcompleted is invoked between 1 and 2.

Is This A Good Question/Topic? 0
  • +

Replies To: Webbrowser.Navigating Skips

#2 lar3ry  Icon User is offline

  • Coding Geezer
  • member icon

Reputation: 310
  • View blog
  • Posts: 1,290
  • Joined: 12-September 12

Re: Webbrowser.Navigating Skips

Posted 24 January 2013 - 09:32 AM

I would try Webbrowser.AllowNavigation = False right after the .Navigate. The doc for .AllowNavigation states:

"Gets or sets a value indicating whether the control can navigate to another page after its initial page has been loaded."

So I think you can do the Navigate, and immediately disallow Navigation, without affecting the initial Navigate.
Was This Post Helpful? 0
  • +
  • -

#3 LilGhost  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 98
  • Joined: 12-October 12

Re: Webbrowser.Navigating Skips

Posted 24 January 2013 - 09:51 AM

Whoops just saw that source is really sloppy because i left out a ") ". Anyways, my issue comes that the initial navigate never access "document completed"
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3224
  • View blog
  • Posts: 10,834
  • Joined: 12-December 12

Re: Webbrowser.Navigating Skips

Posted 24 January 2013 - 11:33 AM

The event is never fired; it needs to handle the Web1 event:

Sub web1_docCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgsHandles web1.DocumentCompleted


or

Sub web1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgsHandles web1.DocumentCompleted

This post has been edited by andrewsw: 24 January 2013 - 11:35 AM

Was This Post Helpful? 0
  • +
  • -

#5 LilGhost  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 98
  • Joined: 12-October 12

Re: Webbrowser.Navigating Skips

Posted 24 January 2013 - 12:04 PM

View Postandrewsw, on 24 January 2013 - 11:33 AM, said:

The event is never fired; it needs to handle the Web1 event:

Sub web1_docCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgsHandles web1.DocumentCompleted


or

Sub web1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgsHandles web1.DocumentCompleted

i renamed the sub the actual webbrowser control is still called WebBrowser1. I just have a different name on the sub that handles the object.

Either way, i believe i just need to do this with webrequests instead of a browser controller.

This post has been edited by LilGhost: 24 January 2013 - 12:05 PM

Was This Post Helpful? 0
  • +
  • -

#6 lar3ry  Icon User is offline

  • Coding Geezer
  • member icon

Reputation: 310
  • View blog
  • Posts: 1,290
  • Joined: 12-September 12

Re: Webbrowser.Navigating Skips

Posted 24 January 2013 - 04:07 PM

View PostLilGhost, on 24 January 2013 - 10:51 AM, said:

Whoops just saw that source is really sloppy because i left out a ") ". Anyways, my issue comes that the initial navigate never access "document completed"

OK, but you don't say if you tried the AllowNavigate = False right after the .Navigate. Did you try it?

I'd test it myself, but I don't know offhand of any reditected pages.
Was This Post Helpful? 0
  • +
  • -

#7 LilGhost  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 98
  • Joined: 12-October 12

Re: Webbrowser.Navigating Skips

Posted 24 January 2013 - 04:35 PM

View Postlar3ry, on 24 January 2013 - 04:07 PM, said:

View PostLilGhost, on 24 January 2013 - 10:51 AM, said:

Whoops just saw that source is really sloppy because i left out a ") ". Anyways, my issue comes that the initial navigate never access "document completed"

OK, but you don't say if you tried the AllowNavigate = False right after the .Navigate. Did you try it?

I'd test it myself, but I don't know offhand of any reditected pages.

I decided just to go with HttpWebRequests and just set ".AllowAutoRedirect = False". Seemed a lot easier after i figured out how to store the cookie.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1