HTTPS Post返回操作超时 [英] HTTPS Post returns operation time out
本文介绍了HTTPS Post返回操作超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i必须使用json数据执行https发布
我的下面代码完全针对http请求运行,但是当我执行https时请求我有时间错误
http& https都托管在默认端口上,即80和80端口。分别为443。这是我的代码
私人 功能 SendRequest( ByVal uri 作为 Uri, ByVal jsonDataBytes 作为 字节(), ByVal contentType 作为 字符串, ByVal 方法作为 字符串,可选 ByVal jsonval 作为 字符串 = ) as 字符串
开启 错误 GoTo ReqErr
req.ContentType = application / x-www-form-urlencoded
1689:req.Headers.Add ( data,jsonval)
使用 client As 新 Net.WebClient
Dim reqparm As 新 Specialized.NameValueCollection
reqparm.Add(< span class =code-string> data,jsonval)
reqparm.Add( ContentType, application / x-www-form-urlencoded)
Dim responsebytes = client.UploadValues(uri, POST ,reqparm)
Dim responsebody =( New Text.UTF8Encoding).GetString (responsebytes)
Dim response = req.GetResponse()。GetResponseStream ' req.GetResponse()。GetResponseStream()
结束 使用
退出 功能
ReqErr:
ErrHandler(错误, SendRequest [uploadData()])
恢复 下一步
结束 功能
任何人都可以帮我这个。
解决方案
HI
i have to do the https post with json data
my below code runs perfectly for http request but when i do https request i get time out error
http & https both have hosted on a default ports i.e port 80 & 443 respectively. here is my code
Private Function SendRequest(ByVal uri As Uri, ByVal jsonDataBytes As Byte(), ByVal contentType As String, ByVal method As String, Optional ByVal jsonval As String = "") As String
On Error GoTo ReqErr
req.ContentType = "application/x-www-form-urlencoded"
1689: req.Headers.Add("data", jsonval)
Using client As New Net.WebClient
Dim reqparm As New Specialized.NameValueCollection
reqparm.Add("data", jsonval)
reqparm.Add("ContentType", "application/x-www-form-urlencoded")
Dim responsebytes = client.UploadValues(uri, "POST", reqparm)
Dim responsebody = (New Text.UTF8Encoding).GetString(responsebytes)
Dim response = req.GetResponse().GetResponseStream 'req.GetResponse().GetResponseStream()
End Using
Exit Function
ReqErr:
ErrHandler(Err, "SendRequest[uploadData()]")
Resume Next
End Function
Can anyone help me on this.
解决方案
这篇关于HTTPS Post返回操作超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文