Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Referer header in asp.net

Tags:

c#

asp.net

  This should be an easy question, but I've been unable to solve it. I'm trying to change the Referral header prior to redirecting the page of an HttpResponse object. I know this can be done in an HttpWebResponse, but can't get this to work for a standard Page.Response.
  I'm trying to just set the referer header to look like it originated from a temp page on my site (this is for analytics tracking for an external system).
 Is this possible to do??
 I've tried to use the code below (as well as variations such as Response.AppendHeader and Response.AddHeader), however the Referer always shows as the page that the Request initiated from.

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

If not via .net can this be accomplished via js?
Thanks!

like image 943
Summit Avatar asked Oct 27 '11 21:10

Summit


1 Answers

Referer is controlled (and sent) by the client. You can't affect it server-side. There may be some JavaScript that you could emit that'd get the client to do it - but it's probably considered a security flaw, so I wouldn't count on it.

like image 167
Mark Brackett Avatar answered Oct 12 '22 11:10

Mark Brackett