tags:

views:

136

answers:

4

I need to create HTTPS call a to remote server that return a data the response of that server dose not include a valid HTTP protocol
and i am getting that error

System.Net.WebException: The server committed a protocol violation. Section=ResponseStatusLine

i all ready did that useUnsafeHeaderParsing

but that did not help probably because the HTTP protocol is implement so badly

can i tell .net to skip the validation at all or use a class that will not validate the HTTP protocol

when i am using a browser i can see the response

A: 

You could use the ServerCertificateValidationCallback callback to ignore certificate validation errors:

ServicePointManager.ServerCertificateValidationCallback = 
    (sender, certificate, chain, sslPolicyErrors) => true;

This is a static property which could be set before performing the HTTP request.

Darin Dimitrov
this will tell the server to ignore the Certificate but not the http potocol
Shvilam
A: 

You most likely have a problem on the other side of the server. I would be willing to bet that you are not getting through to the other site at all. If you're talking to a standard Apache or IIS server, they do a pretty good job of implementing HTTP. Your connection may be interrupted. Try doing your operation using a web browser and see if it works.

Dave Markle
when i am using a web browser it is working fine.In the other side it an application probably been waiting in c that implement the HTTP protocol by them self no a IIS or Apache
Shvilam
A: 

HTTP is a fairly simple protocol on top of TCP. You can use a plain socket, and send the GET command yourself.

MSalters
how can i do it where can i find a code sample
Shvilam
+1  A: 

I the end i did have chaise and i wrote some simple code in VB6
I turn it to a DLL registered that DLL and add referens to .net project
he made the call fro me VB6 dose not preform HTTP protocol validation
ugly but working

Option Explicit

Dim UrlStr As String

Public Sub InitUrlStr(ByVal pUrlStr As String)
   UrlStr = pUrlStr
End Sub

Public Function SendHttpsRequest(ByVal pXml As String) As String
   Dim WinHttp
   Dim PostData

   Set WinHttp = CreateObject("MSXML2.XMLHTTP")

   PostData = pXml

   WinHttp.Open "GET", UrlStr & PostData, False

   WinHttp.Send ' Send request using https
   SendHttpsRequest = WinHttp.responseText  ' assign to local variable

End Function
Shvilam