title: setting the http referrer using c#
body: <p>I have the following C# code that creates a http request for a given url although I need to view the webpage.  Is it possible to create a web request to allow me to control the http referrer value with also being able to see the destination web page?  Right now it looks like this app sets the referrer correctly although I want to see <a href="http://localhost:8000" rel="nofollow">http://localhost:8000</a> in a browser when the app finishes..</p>
  
  <p>Many thanks,</p>
  
  <pre><code>class Program
  {
      const string MyUrl = "http://localhost:8000";
  
      static void Main(string[] args)
      {
          var myHttpWebRequest = (HttpWebRequest)WebRequest.Create(MyUrl);
  
          myHttpWebRequest.Referer = args[0];
  
          var myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
  
          var streamResponse = myHttpWebResponse.GetResponseStream();
  
          if (streamResponse != null) streamResponse.Close();
  
          myHttpWebResponse.Close();
          Console.WriteLine("Referer to the site is:{0}", myHttpWebRequest.Referer);
          Console.Write(Console.ReadLine());
      }
  }
  </code></pre>
  
  <p>}</p>