• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2428
  • Last Modified:

WebBrowser Control - Setting Referrer

I am writing a VB program to do some automated web processing.  I need to follow a link on a page, but I can't set it directly as  URL, as the target verifies the referring page.  You must click on the link on the main page for it to work, so the referrer property is set properly.

Is there a way to do this through the WebBrowser Object?
1 Solution
WebBrowser1.Navigate "http://www.yahoo.com"
are you saying that the web page you are on needs to be called from a previous page?   Maybe there is a cookie placed on your machine on the previous page.  

When you get the the second page.. copy the url and see if you can use the navigate feature....

If it will not work then you will need to go to the first page.. and after it loads up, then navigate to the second.
rmichelsAuthor Commented:

The navigate function works fine. I already have that.  That does not answer my question.

The navigate command is the same as if you typed in an address on Internet Explorer.

There is a property on explorer that holds the refering page.  This gets set when you *click* on a link on the page.

Entering an address directly does not set the referring page.

What I'm looking for is a way to follow a link on a page, without using the navigate command for that link.  I use the Navigate method to get to the first page, then from there I need an alternate method to follow a link.

The target web page is checking the referring page, and it must be set or the navigate will get rejected by the target web page
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Along for the ride id like to know this too.
Not sure how to but according to the documentation, in the following sub the referrer url should be available (therefore changed before the navigate2 event occures)

Private 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)

End Sub

Have used the Cancel and URL variables to change the contents and thus where the webbrowser goes to.
Try and add this to your project and set up a few dummy .htm to referrer to and see what variable contains the URL.
Might give you an idea which one to edit to add what you need.
The header you want to add would be HTTP_REFERER--  note it's mispelled.  If that's actually what they're checking, they could just as easily be checking for a cookie, but either way the idea is the same (you need to add some additional header information)

The webbrowser control seems to automatically tack on the HTTP for the headers listed in its parameters-- so the following looks like it adds the proper header.

WebBrowser1.Navigate2 myUrl, , , , "REFERER: http://www.somewhere.com/somepage.htm" & vbCrLf
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now