Click here to Skip to main content
15,905,967 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
There are many restriction in the use of both Urlreferrer and HTTP_REFERRER. So, is there any alternative for the both.

Actually I am facing the problem the both are working fine on my local machine but not giving result on live environment.

Is there any alternative to the above.

Here is the scenarios:

There is a site say - it captures the incoming urls at Page_Load

user is coming from other sites like;

Any suggestion/solution will be most appreciable.
Updated 19-Jul-22 13:26pm
[no name] 26-Aug-10 8:19am    
Your example is not clear. What is wrong with?
Gaurav Aroraa 27-Aug-10 7:30am    
Actually main issue is I used both urlreferrer and HTTP_REFERRER to detect incoming user urls. Which is working fine in local and test environment but its not working in production environment. All environments have same configuration and securities.

eg. on site there is a link which send user to site now in the default landing page of we are checking the incoming url which is in this case by using above and facing problem in production environment

You will find value in the Request.UrlReferrer only if the current request is initiated by clicking on a Link at the current web application. Otherwise, if the request is redirected to a page (Be it from the current web site or a different web site) using Response.Redirect, you will find the Request.UrlReferrer value to be null.

As a workaround, when you redirect to your target page (From within the current site or from the other sites), you can append a QueryString parameter (Say,, Making sure you encode the FromUrl value). This QueryString parameter value will contain the URL from where the current request is originated.

I used this technique in one of my project. Hope, this will help you.
Share this answer
Gaurav Aroraa 26-Aug-10 14:45pm    
Sorry I did not agree with you the same contains value when user coming from outside current application. I wrote its working fine in locally but the problem is on production.
Please check this :

I know the querystring technique but its hard to change each and evrylink on any application if the querystring value will change in future
Al-Farooque Shubho 27-Aug-10 0:01am    
It's OK if you don't agree with me.

I am not clear about your local environment. But, in real system, the Request.UrlReferrer will have value only if user clicked a HyperLink to navigate to this page. Check out this link :

I also had an MSDN reference, need post that once I find.
Gaurav Aroraa 30-Oct-14 3:13am    
@AlFarooqueShubho - we found one another way to do this. I will be posted here. In between can you please post MSDN link, you mentioned.
Gaurav Aroraa 25-Oct-14 15:28pm    
laterally, I noticed there is no good solution available for this. I accepted your answer
I found an easier solution in

Dim MyReferrer As Object = Request.UrlReferrer()
If Len(MyReferrer) > 0 Then
MsgBox("it's null")
End If
Share this answer
CHill60 20-Jul-22 3:20am    
Except the question was tagged C# and whilst "easier" this will put a message box up on the non-existent screen on the host server. Strictly speaking a string of length zero is not null it's empty. None of this helps anyone overcome the actual problem, unlike the 10 year old accepted solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900