以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]关于hc.FormData.Add模拟表单的异常  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=177966)

--  作者:xubing051018
--  发布时间:2022/6/13 10:19:00
--  [求助]关于hc.FormData.Add模拟表单的异常
客户端程序代码如下:
Dim http,gd As String
http = "http://192.168.3.27:10086/clientShipYMCheck.htm"
Dim hc As New HttpClient(http)

    Dim od As String = "2259"
    hc.FormData.Add("md","LoadPur")
    hc.FormData.Add("id",od)
    hc.Timeout = 100
    gd = hc.GetData()

    hc.FormData.Clear
    hc.FormData.Add("md","LoadTransQty")
    hc.FormData.Add("id",od)
    \'hc.Timeout = 100
    gd = hc.GetData()

以上代码,如果不执行最后一行,程序运行没有问题,
如果加上执行最后一行,会报错,

错误内容:
基流不可读。
参数名: stream
请教这是什么问题,要怎么修改。

--  作者:有点蓝
--  发布时间:2022/6/13 10:24:00
--  
每次请求都需要一个新的HttpClient

Dim http,gd As String
http = "http://192.168.3.27:10086/clientShipYMCheck.htm"
Dim hc As New HttpClient(http)

    Dim od As String = "2259"
    hc.FormData.Add("md","LoadPur")
    hc.FormData.Add("id",od)
    hc.Timeout = 100
    gd = hc.GetData()

hc = New HttpClient(http)
    hc.FormData.Add("md","LoadTransQty")
    hc.FormData.Add("id",od)
    hc.Timeout = 100
    gd = hc.GetData()