• 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

Please log in or register to answer this question.

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 1
5,680 points

Related questions

1 vote
1 answer 488 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 135 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, 2020 alecxe 7.5k points
1 vote
1 answer 46 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 22 views
Problem: Suddenly my whole project stopped compiling at all, showing the following message: Program 'path_to_obj_project_folder' does not contain a static 'Main' method suitable for an entry point I made no changes to project properties, just added some classes, moved some other classes into ... where it should be, file App.xaml was not modified at all :( What should I do to make it work again?
asked May 1 Yeamin 22k points
0 votes
1 answer 151 views
0 votes
1 answer 60 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, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 3 views
Problem: I had a function which I need to Refresh the data grid view. When I deploy the program it automatically close the program. I have a MSSQL Server in my side. I tried to fix my function several times but it only works fine in my environment. Here is my code ... Result"].Value.ToString() == "Failed") cardData.DefaultCellStyle.BackColor = Color.Red; await Task.Run(() => DGView.Refresh()); } }
asked May 2 anika11 32.2k points
0 votes
1 answer 2 views
Problem: I'm trying to make some images loop round, kind of like what you'd see in a slot machine. My current code is more of a marquee so the images go from the top to the bottom and while they're moving theres some whitespace ... .ActualHeight; da.Duration = new Duration(TimeSpan.FromSeconds(0.25)); da.RepeatBehavior = RepeatBehavior.Forever; stackPanel1.BeginAnimation(Canvas.TopProperty, da);
asked May 1 ochena 23.3k points
0 votes
1 answer 6 views
Problem: Can anyone please point me in the right direction > This implementation is not part of the windows platform fips validated cryptographic algorithms
asked Apr 23 ummeshani 10.8k points
0 votes
1 answer 9 views
Problem: How to fix this error > This implementation is not part of the windows platform fips validated cryptographic algorithms.
asked Apr 22 ummeshani 10.8k points