Solved

How to get the referral site URL

Posted on 2007-12-05
5
2,422 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

806 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