C# Сервер нарушил протокол. Section=ResponseStatusLine

437
30 марта 2017, 18:01

Возникает ошибка: Сервер нарушил протокол. Section=ResponseStatusLine Ссылку на ресурс дать не смогу. Кто-нибудь знает из-за чего возникает эта ошибка и как её устранить?

Код:

            System.Net.WebRequest request = System.Net.WebRequest.Create("http://...");
            //Указываем системные учетные данные приложения.
            request.Credentials = System.Net.CredentialCache.DefaultCredentials;
            //Указываем сетевые учетные данные текущего контекста безопасности.
            request.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
            // Set the Method property of the request to POST.
            request.Method = "POST";
            // Create POST data and convert it to a byte array.
            string postData = "cmd_conf";
            byte[] byteArray = Encoding.UTF8.GetBytes(postData);
            // Set the ContentType property of the WebRequest.
            request.ContentType = "application/x-www-form-urlencoded";
            // Set the ContentLength property of the WebRequest.
            request.ContentLength = byteArray.Length;
            // Get the request stream.
            Stream dataStream = request.GetRequestStream();
            // Write the data to the request stream.
            dataStream.Write(byteArray, 0, byteArray.Length);
            // Close the Stream object.
            dataStream.Close();
            // Get the response.
            WebResponse response = request.GetResponse();
            // Display the status.
            richTextBox1.Text = ((HttpWebResponse)response).StatusDescription;
            // Get the stream containing content returned by the server.
            dataStream = response.GetResponseStream();
            // Open the stream using a StreamReader for easy access.
            StreamReader reader = new StreamReader(dataStream);
            // Read the content.
            string responseFromServer = reader.ReadToEnd();
            // Display the content.
            richTextBox2.Text = responseFromServer;
            // Clean up the streams.
            reader.Close();
            dataStream.Close();
            response.Close();
READ ALSO
Отображение загрузки файла WebMethod

Отображение загрузки файла WebMethod

Есть WebMethod который принимает html и помещает в pdf файл(в темп юзера)Файл формируется, сохраняется, но это происходит незаметно для пользователя(не...

256
Различие анонимных методов и lambda

Различие анонимных методов и lambda

В чем различие между анонимными методами и lambda-выражениями? В анонимных методах мы можем обойтись без параметров, если даже это и ожидается:

210
Поведение NET Flags атрибута

Поведение NET Flags атрибута

Столкнулся сегодня с загадочным поведением enum с атрибутом FlagsПервый enum из проекта, только имя изменил

255
Как вызывать по одной форме внутри Panel?

Как вызывать по одной форме внутри Panel?

Проблема в том, что вызывая Form2 она открывается несколько раз до бесконечностиМожет есть способ открывать только один раз, и при переходе...

212