Getting HTTP_REFERER value

J

John

Hi

I am trying to save the value of HTTP_REFERER so I can use it later on in
the webform as below;

Public Return_Address as string

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Return_Address = Request.ServerVariables("HTTP_REFERER")
End Sub

The problem is that Return_Address value always comes out blank. What am I
doing wrong?

Thanks

Regards
 
G

Guest

Hi John,

It will be empty the first time you open the page because there is no
referrer. After clicking the hyperlink in the code below, you should see the
value. Let us know how you make out?

<%@ Page Language="VB" %>
<script runat="server">

' Insert page code here
'
Public Return_Address as string

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Return_Address = Request.ServerVariables("HTTP_REFERER")
End Sub

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:HyperLink id="HyperLink1" runat="server"
NavigateUrl="referrer.aspx">HyperLink</asp:HyperLink>
<%= Return_Address%>
</form>
</body>
</html>
 
J

Joe

In general, keep in mind the http version that is making the request. Http
1.0 and http 1.1 requests will yield different results for certain server
variables.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top