Dear Sir;

I have a web-service that communicates with my Desktop application. Usually I used http in the webrequest, but now I want to modify my code to use https. I accessed the links from web browser normally; but I can not access the same link from my desktop application. Below is the code that I use


Public Function Json_Connection(url As String, content As String, ByRef statusCode As HttpStatusCode) As Byte()
dataStream = Nothing
responseFromServer = Nothing


request = HttpWebRequest.Create("" & url)

request.ProtocolVersion = New System.Version(1, 0)

request.Timeout = 120000

request.Method = "POST"

submit = System.Text.Encoding.UTF8.GetBytes(content)

request.ContentType = "application/x-www-form-urlencoded,charset=utf-8"

request.ContentLength = submit.Length

dataStream = request.GetRequestStream()

dataStream.Write(submit, 0, submit.Length)


response = request.GetResponse()

dataStream = response.GetResponseStream()

ms = New MemoryStream()

thisRead = 0

buff = New Byte(1023) {}


thisRead = dataStream.Read(buff, 0, buff.Length)

If thisRead = 0 Then

Exit Do
End If

ms.Write(buff, 0, thisRead)
Loop While True

responseFromServer = ms.ToArray()



statusCode = HttpStatusCode.OK

Catch ex As WebException
If ex.Response IsNot Nothing Then
dataStream = ex.Response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim resp As String = reader.ReadToEnd()
statusCode = DirectCast(ex.Response, HttpWebResponse).StatusCode
resp = ""

statusCode = HttpStatusCode.ExpectationFailed

End If

Catch ex As Exception
statusCode = HttpStatusCode.ExpectationFailed
End Try

Return responseFromServer

End Function

Appreciate for your help and support.