• Register
1 vote

Problem :

Currently I am learning the use of HttpClient class. Also I have started using the HttpClient class to communicate with the web service in my current WPF application.

If I try to make the consecutive GET requests on my same connection then everything works perfectly. But if I try to make the consecutive PUT or PATCH requests on a same connection in this case only my first request executes accurately and also I receive the response correctly but my second request fails and it does not include any body in my request and then I receive the following error

"The server committed a protocol violation. Section=ResponseStatusLine".

I know it is a very common error but it has very few known solutions available which I have already tried. I have tried a solution which involves the setting a useUnsafeHeaderParsing property to the value as true and also set my Keep-Alive property to the value as false in my Web.Config. But somehow it is not working for me.

I am unable to fix above error. I am looking for somebody who can help me in fixing above error.

8 5 2
3,230 points

1 Answer

1 vote

Solution :

I had also faced this issue in the past. After a lot of research on this error I realized my mistake was I was trying to edit my Web.Config file of my WPF application instead of my app.config file.

So if you want to fix above error then you must drop below code in your app.config file at a root of your configuration tag for your WPF application and it will surely fix your problem.

<httpWebRequest useUnsafeHeaderParsing = "true"/>


8 4
5,680 points

Related questions

1 vote
1 answer 246 views
Problem : Facing bellow error the server committed a protocol violation. section=responseheader detail=cr must be followed by lf
asked Nov 8, 2019 peterlaw 6.9k points
0 votes
1 answer 79 views
Problem : I am facing error on below step objUDMCountryStandards.Country = txtMySearchCountry.Text.Trim() != string.Empty ? txtMySearchCountry.Text : null; in the get grid data throws error as below : &ldquo;The calling thread cannot access this object because a different thread owns it.&rdquo; Is there anything wrong with my code?
asked Jan 7 alecxe 7.5k points
1 vote
1 answer 32 views
Problem : In the following step objUDMCountryStandards.Country = txtSearchCountry.Text.Trim() != string.Empty ? txtSearchCountry.Text : null; in get grid data throws the exception as below : The calling thread cannot access this object because a different thread owns it. What is wrong in my code?
asked Dec 28, 2019 alecxe 7.5k points
0 votes
1 answer 15 views
Problem: I have recently joined a new project in WPF C# and at this time I am trying to animate the image to simply move down. I have already found out the "MoveTo" function on an Internet but when I pasted it in my code then the below error occurred: &ldquo; ... button_Click(object sender, RoutedEventArgs e)     {         MoveTo(image, 130);     } } Kindly help me in fixing my above C# code.
asked Jul 28 Raphael Pacheco 4.9k points