Site menu:

Links:

RSS .NET RSS

RSS Engadget

Site search

Categories

September 2010
M T W T F S S
« Aug    
 12345
6789101112
13141516171819
20212223242526
27282930  

Tags

Blogroll

the server committed a protocol violation section= responsestatusline

I’ve got this error and try to spend almost an hour to resolve this:

“the server committed a protocol violation section= responsestatusline” when I tried to get the response back from the payment gateway. It happens when you send HTTP Request one after another on the same page. The solution is to add unsafeheaderparsing to true in web.config and to seet keepAlive property to false from the http request it self

Web.Config

1
2
3
4
5
6
7
8
9
10
11
12
13
<system.net>
		<defaultProxy>
			<proxy usesystemdefault="false" bypassonlocal="true" proxyaddress="http://myproxy"/>
		</defaultProxy>
		<settings>
			<httpWebRequest useUnsafeHeaderParsing="true"/>
		</settings>
    <mailSettings>
      <smtp from="mail@mail.com.au">
        <network host="10.2.30.51"/>
      </smtp>
    </mailSettings >
  </system.net>

Calling Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
   Private Function SendXML(ByVal strSend As String) As Boolean
        Dim blnSuccess As Boolean = False
        Dim objSendXML As XmlDocument
        Dim objRequest As HttpWebRequest
        Dim mywriter As StreamWriter
        Dim objResponse As HttpWebResponse
        Dim objReturnedXML As XmlDataDocument
        Dim objElementRoot As XmlElement
        Dim objElementTransaction As XmlNode
        Dim objElementCreditCardInfo As XmlNode
        Dim x As XmlNode
 
        Dim strApproved As String = String.Empty
        Dim blnCreditCardInfo As Boolean = False
 
        ' Must reset the variable incase of error
        Me._Paid = False
 
        objSendXML = New XmlDocument
        objRequest = WebRequest.Create(strPaymentURL)
 
 
        'if it is using proxy/behind proxy
        If (UseProxy And Not (String.IsNullOrEmpty(ProxyServer))) Then
            objRequest.Proxy = New System.Net.WebProxy(ProxyServer, True)
 
            'if there is credential
            If (UseDefaultCredential) Then
                objRequest.Proxy.Credentials = CredentialCache.DefaultCredentials
            Else
                objRequest.Proxy.Credentials = New NetworkCredential(UserName, Password)
            End If
 
        End If
 
        objRequest.Method = "POST"
        objRequest.ContentLength = strSend.Length
        objRequest.ContentType = "text/xml"
 
        'to solve protocol violation problem
        objRequest.KeepAlive = False

Write a comment