我已经阅读了很多(如果不是所有的话)关于 Web 请求超时的帖子,并且提供的解决方案没有奏效。我从 Big Commerce 获得订单,然后更新 Big Commerce 状态代码。我可以更新 2 个订单,然后我在第三个时超时,无论是星期几还是一天中的时间,每次都超时。
App.Config 文件有:
```
<system.web>
<httpRuntime executionTimeout="180" />
</system.web>
```
代码:
```
Try
Dim strJSON As String = "{""status_id"": 9}"
Dim postBytes As Byte() = System.Text.Encoding.UTF8.GetBytes(strJSON)
For i As Integer = 0 To dto.Rows.Count - 1
strWebOrder = dto.Rows(i).Item("WebOrder")
Dim strHttp As String = "https://api.bigcommerce.com/stores/storeid/v2/orders/" & strWebOrder
Dim request As HttpWebRequest = DirectCast(WebRequest.Create(strHttp), HttpWebRequest)
request.Accept = "application/json"
request.ContentType = "application/json"
request.Headers("X-Auth-Token") = strAuthToken
request.Timeout = 10000
request.AllowWriteStreamBuffering = False
request.SendChunked = True
request.Method = "PUT"
Dim postStream As Stream = request.GetRequestStream()
postStream.Write(postBytes, 0, postBytes.Length)
Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
If response.StatusCode = 200 Then
strErrorRef = "Web " & strWebOrder
strErrorReason = "Order Status Changed to Exported"
strPutMessage = ""
WriteError()
Else
strErrorRef = "Web " & strWebOrder
strErrorReason = "Unable to change Web Order Status to Exported"
strPutMessage = ""
WriteError()
End If
Next
Catch ex As Exception
strErrorRef = "Web " & strWebOrder
strErrorReason = "Unable to change Web Order Status to Exported"
strPutMessage = (ex.ToString)
WriteError()
End Try
```