System.Net.ProtocolViolationException: You must write ContentLength bytes to the request stream before calling [Begin]GetResponse

前端 未结 3 664
隐瞒了意图╮
隐瞒了意图╮ 2021-01-07 23:42

I am getting the

\"System.Net.ProtocolViolationException: You must write ContentLength bytes to the request stream before calling [Begin]GetResponse\

3条回答
  •  天涯浪人
    2021-01-08 00:23

    This finally worked by using:

    using (dataStream = Webrequest.GetRequestStream())
    {
       dataStream.Write(byteArray, 0, byteArray.Length);
    }
    

    Instead of:

    dataStream = Webrequest.GetRequestStream();
    dataStream.Write(byteArray, 0, byteArray.Length); 
    

提交回复
热议问题