Life & Technology

Handful lessons in different areas of technology and life in general.

QuickFix: Server Committed a Protocol Violation Error in .NET

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:

  1. <>
  2. <settings>
  3. <httpWebRequest useUnsafeHeaderParsing=”true”/>
  4. </settings>
  5. </>

With this setting in place inside your web.config file, the error disappear and HTTP response will be displayed.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: