+ Start a Discussion
unidhaunidha 

get referer returning null

Hi,

 

I try to get the referer, but it returning me null when I run it.          

 

Here the code that I put in extension

 

String mktg_ref= (String)ApexPages.currentPage().getHeaders().get('Referer');

 

 

This is example of page that I run https://ap1.salesforce.com/apex/Marketing_coupon?id=a5QV00000004E17

 

Please advise.

 

Thanks,

unid

kiranmutturukiranmutturu

 

do u want to get the id from the url or not? 

 

Generally referer will be useful when the URL that is either included or linked to the current request's URL....i.e if you have 2 pages like x and y and if you call y from x page then you can get the values of from y page by using that referer value...

 

if you just need the id from the given url u can do like below

 

ApexPages.currentPage().getParameters().get('id')

 

unidhaunidha

Hi kiran_mutturu,

 

No, I don't want to get Id. I want to get referer where the page come from.

 

I also try to run  

  system.debug(ApexPages.currentPage().getHeaders());

It return no Referer.

 

If I create a button in the object itself and link it to the page, it will return the Referer. But if I create site and run the page, it won't.

 

I just wonder how to ensure Referer is available in Header?

 

 

Thanks,

unidha