QuickFix: Server Committed a Protocol Violation Error in .NET
August 23, 2012
Posted by on
While testing the Hacker News website, I encountered a WebException error which is my first time encountering this kind of message:
The server committed a protocol violation. Section=ResponseStatusLine
I thought this is caused by HAP but I was wrong, a quick MSDN search says that this error occurred because the server response is not a valid HTTP response and has a WebExceptionStatus of ServerProtocolViolation.
If you don’t own the server, chances are you never get to fix the problem on the server itself but Microsoft provided a HttpWebRequestElement property that will ignore validation errors that will occur during parsing:
With this setting in place inside your web.config file, the error disappear and HTTP response will be displayed.