Search code examples
windows-phone-7windows-phone-7.1user-agentbackground-transfer

Setting the user agent in a Windows Phone 7.1 (SDK 7.1.1) BackgroundTransferRequest


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.


Solution

  • 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";