Q:

The server committed a protocol violation. Section=ResponseStatusLine ERROR

I have created a program, tried to post a string on a site and I get this error: 

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

after this line of code:
gResponse = (HttpWebResponse)gRequest.GetResponse(); 

How can I fix this exception?

A:

Try putting this in your app/web.config:
<system.net>
    <settings>
        <httpWebRequest useUnsafeHeaderParsing="true" />
    </settings>
</system.net>

If this doesn't work you may also try setting the KeepAlive property to false.

A:

Sometimes this error occurs when UserAgent request parameter is empty (in github.com api in my case).
Setting this parameter to custom not empty string solved my problem.

A:

The culprit in my case was returning a No Content response but defining a response body at the same time. May this answer remind me and maybe others not to return a NoContent response with a body ever again. 
This behavior is consistent with 10.2.5 204 No Content of the HTTP specification which says:

The 204 response MUST NOT include a message-body, and thus is always
  terminated by the first empty line after the header fields.

