C#: HttpClient, The server committed a protocol violation. Section=ResponseStatusLine

放肆的年华 提交于 2019-12-05 01:35:03

The underlying problem is that the PATCH response includes content within the body of the response. Ensure that the server does not send content when sending a 204 No Content.

After much debugging and reading, I realized I was trying to edit the Web.Config file of the WPF application instead of the app.config file!

So if you drop this code in the app.config file at the root of the configuration tag for a WPF application, it fixes the problem.

<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing = "true"/>
</settings>
</system.net>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!