request.GetResponse()在vb.net中给出了“操作已经超时。” [英] request.GetResponse() has giving “The operation has timed-out.” in vb.net
问题描述
我在vb.net中获取POST方法Web请求的响应时遇到问题,并且GET请求正常工作并获得响应,而相同的请求在C#中正常工作,其后执行相同的步骤。所以,任何人都可以帮我解决这个问题
这里Url是一个弹性搜索引擎,postData变量中的数据是一个json字符串,响应将是也是一个json字符串
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(HOSTIP:9200 / es5078_1 / _search?pretty =真的)
request.Method =POST
Dim postData As String = CGeneral.gstrMsgNC(236)
request.ContentType =application / x-www-form-urlencoded
request.ContentLength = postData.Length
request.Timeout = 100000
Dim writer As StreamWriter = New StreamWriter(request.GetRequestStream())
writer.Write(postData)
请求。 Expect =
request.AllowAutoRedirect = True
request.AllowWriteStreamBuffering = True
昏暗的响应作为系统.Net.HttpWebResponse = request.GetResponse ()
Dim responseReader As StreamReader = New StreamReader(response.GetResponseStream())
Dim result As String = responseReader.ReadToEnd()
I'm facing problem in getting response for a POST method web request in vb.net and the GET request is working properly and getting the response, while the same request is working fine in C# with the same steps followed here. So, can any one help me to try to sort out this
Here Url is a Elastic search engine and the data in postData variable is a json string and the response will also be is a json string
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("HOSTIP:9200/es5078_1/_search?pretty=true")
request.Method = "POST"
Dim postData As String = CGeneral.gstrMsgNC(236)
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = postData.Length
request.Timeout = 100000
Dim writer As StreamWriter = New StreamWriter(request.GetRequestStream())
writer.Write(postData)
request.Expect = ""
request.AllowAutoRedirect = True
request.AllowWriteStreamBuffering = True
Dim response As System.Net.HttpWebResponse = request.GetResponse()
Dim responseReader As StreamReader = New StreamReader(response.GetResponseStream())
Dim result As String = responseReader.ReadToEnd()
推荐答案
几个理由,请查看此主题
System.Net.WebException:操作已超时 [ ^ ]
Few reasons, check this thread
System.Net.WebException: The operation has timed out[^]
这篇关于request.GetResponse()在vb.net中给出了“操作已经超时。”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!