Solved

How to get the referral site URL

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Download a website to hdd 2 52
Having problem getting this to work 2 21
replace all occurrences within a string 8 19
Window.Open() is showing a blank page 9 17
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

863 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

28 Experts available now in Live!

Get 1:1 Help Now