c # - Webrequest sender ikke overskrifter til Host

Indlæg af Hanne Mølgaard Plasc

Problem



Min kode


Jeg forsøger at sende brugerdefinerede overskrifter til en vært, men da de modtog dataene, modtager de ikke overskrifterne:


request = (HttpWebRequest)WebRequest.Create(Common.GatewayUrl(Gateway, UsingTestGateway));
strCookieHeader = "[machine=" + ThreeDSecure.Cavv + " path=null domain=null; ]";
request.Headers.Add("cookies", strCookieHeader);
//request.Headers.Add("machine", ThreeDSecure.Cavv);
//request.Headers.Add("path", "null");
//request.Headers.Add("domain", "null");
//request.ContentType = Common.ContentType(Gateway);
//request.Headers[HttpRequestHeader.Cookie] = strCookieHeader;
//request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
request.Credentials = merchantCredentials;
request.ContentLength = requestData.Length;
request.Timeout = 60000;
request.Method = "POST";

sw = new StreamWriter(request.GetRequestStream());
sw.Write(requestData);
sw.Flush();
sw.Close();

response = (HttpWebResponse)request.GetResponse();
sr = new StreamReader(response.GetResponseStream());
responseData = sr.ReadToEnd();

sr.Close();

Bedste reference