views:

257

answers:

4

I have a asp.net application that i use for traffic tracking.

I get a incoming visitor from several source websites and redirect the visitor to the target website using Response.Redirect(url);

The problem is that currently the referer shown to the target website (after i redirect) is of the url of the source website and not my website.

how do i clear/change the referer before using the Response.Redirect?

This is my code of Default.aspx:

public partial class _Default : System.Web.UI.Page 
    { 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            if (!IsPostBack) 
            { 
                try 
                { 

                    Response.Redirect(url); 
                } 
                catch (System.Threading.ThreadAbortException) { } 
            } 
        } 

Thanks.

A: 

The referer is controlled by the browser, so there's probably not a whole lot you can do to change its mind. There is a hack you can put to use, but it is just that.

Have you tried doing a Server.Transfer instead?

48klocs
Server.Transfer maintains the original URL in the browser. i want to redirect.
mike
A: 

From the ASPX page try one these solutions:

1.. Try adding a meta refresh tag to the header of your aspx page from the codebehind.

Response.AppendHeader("Refresh", "0; url=http://targetsite.com");

2.. Add Javascript to your page from the codebehind

Page.RegisterStartupScript("myScript", "<script language=JavaScript>window.location = "http://targetsite.com";&lt;/script&gt;");
Ed B
Tried both of them. it help but still some of the traffic gets the wrong referrer.
mike
A: 

Like 48klocs mentioned. There just isn't a good way to do this. Been down the road too and it sucks.

CDeutsch
A: 

http://en.wikipedia.org/wiki/HTTP_referrer

Some clients and anti virus software will remove or even fill it with junk.

bleevo