Set Referer header in asp.net

  This should be a simple question, but I could not solve it. I am trying to change the Referral header before redirecting the page of an HttpResponse object. I know that this can be done in HttpWebResponse, but cannot make it work for standard Page.Response.
  I'm trying to just set the abstracting title so that it looks like it was created on the temporary page of my site (this is for tracking analytics for an external system).

  Can this be done? I tried using the code below (as well as options like Response.AppendHeader and Response.AddHeader), however Referer always displays as the page from which the request was initiated.

      Response.Headers.Add("Referer", "http://test.local/fromA");
      Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri);

If not via .net, can this be done via js?
Thank!

+5
source share
2 answers

The referent is controlled (and sent) by the client. You cannot affect it on the server side. There may be some kind of JavaScript that you could emit to get the client to do this, but this is probably considered a security flaw, so I won’t count on it.

+6
source

The referrer is set by the client, not the server. It is useful to include in the request, not the response, because it points to the URL where the request came from.

+5
source

All Articles