使用httprequest标头


byte[] requestBytes = System.Text.Encoding.ASCII.GetBytes(message);
request.Method = "POST";
request.ContentType = "text/xml;charset=utf-8";
request.ContentLength = requestBytes.Length;
request.Headers.Add(string.format("infoAsString, {0}", infoAsString))
using (Stream requestStream = request.GetRequestStream())
{      
    requestStream.Write(requestBytes, 0, requestBytes.Length);
    requestStream.Close();
}

iv尝试了此操作,并在代码达到请求时进行调试。提出的标题:指定的值没有一个':'saparator。参数名称:标题

也尝试了:

request.Headers.Add("infoAsString, {0}", infoAsString)

&

request.Headers.Add("infoAsString : {0}", infoAsString)

&

request.Headers.Add(infoAsString)

没有欢乐...请建议

标题是NameValueCollection,并带有名称和值的成员。

你应该做

request.Headers.Add("infoAsString", infoAsString)

相关内容

  • 没有找到相关文章

最新更新