1

It's very easy to change the referer by simply setting the appropriate header, however, I cannot find a way to change the user agent ("ZDM/4.0; Windows Mobile 7.0;") to any other value. I tried the following code so far:

var request = new BackgroundTransferRequest(new Uri("http://www.somedomain.net"));
request.Headers[Convert.ToString(HttpRequestHeader.UserAgent)] = "AgentSmith";
request.Headers[Convert.ToString(HttpRequestHeader.Referer)] = "MyReferer";

Any thoughts? Your help will be very much appreciated.

UnclePaul
  • 515
  • 5
  • 17

1 Answers1

3

Convert.ToString(HttpRequestHeader.UserAgent) returns "UserAgent", but the HTTP Header is "User-Agent"; try the code like this:

var request = new BackgroundTransferRequest(new Uri("http://www.somedomain.net"));
request.Headers["User-Agent"] = "AgentSmith";
request.Headers["Referer"] = "MyReferer";
Pedro Lamas
  • 7,185
  • 4
  • 27
  • 35
  • I tried so hard in getting nice and readable code freed from all the hard-coded strings, but totally overlooked the potential problems. Ha! Thank you Pedro. – UnclePaul Apr 12 '12 at 23:06