Solved

How to get the referral site URL

Posted on 2007-12-05
5
2,387 Views
Last Modified: 2009-02-18
How do I capture the referral site(From which the user came to my site. The link on which brought my user to my site) and take the user back to that page when he is done with mine?

0
Comment
Question by:netsol07
  • 3
5 Comments
 
LVL 22

Expert Comment

by:RedKelvin
ID: 20415842
Hi,
To get the referring Url, you can use

Request.UrlReferrer.ToString()

and you can use the response redirect, to redirect the user back to that url, so the complete operation would be like this

Response.Redirect(Request.UrlReferrer.ToString())
0
 
LVL 22

Expert Comment

by:RedKelvin
ID: 20415855
oh, I should also point out that you need to use the System.Web.HttpContext.Current namespace for the request and response objects. put this at the top of your code outside the class


imports System.Web.HttpContext.Current

Open in new window

0
 
LVL 7

Expert Comment

by:nisarkhan
ID: 20415944
You can use Request.ServerVariables("HTTP_REFERER") to get the referral URL in your ASP pages. Read more about the Request.ServerVariables collection here:

http://www.aspdev.org/articles/asp-servervariables/
0
 

Author Comment

by:netsol07
ID: 20423419
Hi RedKelvin,

I've did what you suggested as my application is in asp.net.
I'm wondering what would be the better way to test it because I'm always getting "" for refuri.
(I have placed the new site link in one of my old apps and ran from there)
0
 
LVL 22

Accepted Solution

by:
RedKelvin earned 250 total points
ID: 20448128
did the previous page link to that page, otherwise the referrer will be ""
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now