• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 269
  • Last Modified:

ASP Linking

I know in PHP, the code to grab a link is echo $link

How can I grab a URL from a previous page using ASP?

1 Solution


[providing that the page the script placed on is not the startup page for the browser session, was not hard coded into the address bar or not opened as a favorite.]

- tushar
Here ya go.
    Response.Write "Referer: " & Request.ServerVariables("HTTP_REFERER")

This won't work in all cases though.  Below is a list of what will and will not work.

The situations where this ServerVariable works
---clicking on a straight HTML <a href> link;
---submitting a form, using POST or GET, from a submit button, <input type=image> or client-side script (form.submit())

The situations where it doesn't work:
---clicking on a Favorite, History, or the recently-typed URLs list
---clicking on 'Home' in IE's toolbar, or an item in IE's 'Links' toolbar
---using location.href or location.replace() in client-side JScript/JavaScript/VBScript
---using HierMenus (details)
---typing the URL directly in the browser and hitting Enter or clicking 'Go'
---launching a clickable URL from an e-mail or MS Office document
---using Response.Redirect / Server.Transfer
---using Response.AddHeader (302) or <meta http-equiv=refresh> to redirect
---misspelling the variable name (many people assume HTTP_REFERRER).
---Obviously, this variable cannot be relied upon for many situations.
Hope this helps,

Michael Grassman
{personal website url removed - ee_ai_construct, cs moderator}
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now