function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

HTTP Header - Referer field not send using PageReference in IE

Hey all,


Hitting a wall in trying to figure this one out.


At a high level:

VF Page with a command button whose action returns a pagereference to an external site. This external site checks the referer field in the http headers to determine if it allows access or not.


If I use Firefox 3, the referer header is sent and the external site accepts the request. The exact same process in Internet Explorer (7 and 8) fails, as the referer field is not included in the request headers.


VF Page (cut out the unrelated code)

<apex:commandButton value="Submit Order" action="{!submit}" rendered="{!DisplayForFinalApprover}"/>


public PageReference submit(){
PageReference pageRef;
pageRef = new PageReference('');
return pageRef;		

The above works in FF but not IE. 


Now if I put the use outputlink as follows:

<apex:outputLink value="" id="theLink">Submit Order</apex:outputLink>


Then the referer field is in the request headers and the external site accepts the request. both in IE and FF.


So why does the PageReference work in Firefox, but not in Internet Explorer? Why is the referer field not sent?


Firstly, using the Referer header for anything meaningful (esp authentication) is a bad idea for several reasons. But assuming you don't have control over that external page and need to rely on it, you'll have to work around it by using client-side javascript, because IE doesn't pass referer in several circumstances like this. See this article for details:


Hope that helps


Jeremy Kraybill


Thanks for your reply Jeremy,


You're correct, I don't have control over the external page so I reliant on getting the referer header sent.


The link you sent does seem to fit the issue I'm seeing. But I'm not 100% sure on how to implement the workaround. I understand how to put the javascript code in the link on my page, and how it works. But I don't know how I might pass paramaters to it.


The code I gave in my first post was very much a simplistic version of the actual code. In reality the submit method contains fairly complex logic that results in the method returning one of several different possible PageReferences and also updating the state of some objects.


So how do I ensure that the updates in the submit action are carried out, the correct page reference returned and the correct link and parameters are sent to the goto javascript function?


I'm assuming it will take the form of

<apex:commandButton value="Submit Order" action="{!submit}" rendered="{!DisplayForFinalApprover}" oncomplete="goto(***insert link here**)"/>


But how do ensure the correct link is passed to the goto function? Another method?