Pergunta

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.

Foi útil?

Solução

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";
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top