Hi to all I'm trying to change the headers of a request, I'm trying to simulate a request from different browsers, languages...
The problem is when I try to change the headers I receive an exception(see below), this is the code I'm using:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Headers.Set(HttpRequestHeader.UserAgent, httpRequest.ServerVariables["HTTP_USER_AGENT"]);
request.Headers.Set(HttpRequestHeader.Accept, httpRequest.ServerVariables["HTTP_ACCEPT"]);
request.Headers.Set(HttpRequestHeader.Referer, httpRequest.ServerVariables["HTTP_REFERER"]);
request.Headers.Set(HttpRequestHeader.AcceptLanguage, httpRequest.ServerVariables["HTTP_ACCEPT_LANGUAGE"]);
Is this possible to do?
Thanks in advanced :'(
Exception:
"System.ArgumentException: This header must be modified using the appropriate property.\r\nParameter name: name\r\n at System.Net.WebHeaderCollection.ThrowOnRestrictedHeader(String headerName)\r\n at System.Net.WebHeaderCollection.Set(String name, String value)\r\n at System.Net.WebHeaderCollection.Set(HttpRequestHeader header, String value)\r\n at