System.Net.WebException:服务器已运行协议违规.Section = ResponseStatusLine

时间:2017-02-09 08:50:26

标签: c# .net exception server webrequest

我已在此处阅读了有关此主题的所有答案。它只是没有解决我的问题。

每当我尝试连接到以下服务器时,我都会遇到以下异常:

  

System.Net.WebException:Der Server hat eineProtokollverletzungausgeführt。第= ResponseStatusLine      bei System.Net.HttpWebRequest.GetResponse()

这是我的代码:

string Url = "http://hbci01.fiducia.de:3000";
string Message = "HBCI-Message";

var req = WebRequest.Create(Url) as HttpWebRequest;

byte[] data = Encoding.ASCII.GetBytes(Helper.EncodeTo64(Message));

req.Method = "POST";
req.Timeout = 10000;
req.ContentType = "application/octet-stream";
req.ContentLength = data.Length;
req.KeepAlive = false;

req.ServicePoint.Expect100Continue = true;

req.UserAgent = "User-Agent";

req.Headers.Add("Header", "Header");

using (Stream reqStream = req.GetRequestStream())
{
    reqStream.Write(data, 0, data.Length);
    reqStream.Flush();
}

是的,服务器正在侦听端口3000。

有没有人有解决方案?

1 个答案:

答案 0 :(得分:1)

将远程服务器更换为实际上没有损坏的HTTP。