The server committed a protocol violation. Section=ResponseStatusLine ERROR

manish patel picture manish patel · Mar 20, 2010 · Viewed 151k times · Source

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?

Answer

Darin Dimitrov picture Darin Dimitrov · Mar 20, 2010

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.