By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,814 Members | 1,671 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,814 IT Pros & Developers. It's quick & easy.

Getting HTTP_REFERER value

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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>
"John" wrote:
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

Nov 18 '05 #2

P: n/a
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.
"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:FA**********************************@microsof t.com...
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>
"John" wrote:
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

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.