当前位置: 代码迷 >> VB Dotnet >> 这段代码提效数据后,没有效果,帮忙看一上错在哪里
  详细解决方案

这段代码提效数据后,没有效果,帮忙看一上错在哪里

热度:6745   发布时间:2013-02-26 00:00:00.0
这段代码提效数据后,没有效果,帮忙看一下错在哪里?
本帖最后由 pengwei0417 于 2012-12-01 23:07:15 编辑
    Dim url As New Uri("http://110.8.64.9/tp/template.asp")
        Dim myreq As HttpWebRequest
        myreq = HttpWebRequest.Create(url)
        myreq.Method = "POST" '设置请求方法
        myreq.ContentType = "application/x-www-form-urlencoded"
       'textbox2.text="questselect1=321&submit1=%de%dskksdf&cname=&iDE="
        Dim datastr As String = TextBox2.Text.Trim
        myreq.ContentLength = datastr.Length
        Dim encoding As New ASCIIEncoding
        Dim byte1 As Byte() = encoding.GetBytes(datastr)
        myreq.ContentType = "application/x-www-form-urlencoded"
        myreq.Headers.Add("X_FORWARDED_FOR", "10.71.12.25")
        myreq.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"
        myreq.Referer = "http://10.82.64.9/tp/template.asp"
        myreq.Headers.Add(HttpRequestHeader.AcceptLanguage, "zh-cn")
        myreq.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate")

        myreq.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)"

        myreq.ContentLength = byte1.Length

        myreq.Headers.Add(HttpRequestHeader.CacheControl, "no-cache")
        myreq.Headers.Add(HttpRequestHeader.Cookie, "ASPSESSIONIDQQASCARB=IJGNFCIDILJNGLOLGEHJGAGH")

        Dim newstream As Stream = myreq.GetRequestStream()
        newstream.Write(byte1, 0, byte1.Length)
        newstream.Close()
        '响应部分
        Dim myres As HttpWebResponse = myreq.GetResponse()
        Dim mystream As Stream = myres.GetResponseStream
        Dim srreader As New StreamReader(mystream)
        TextBox3.Text = srreader.ReadToEnd


虽然可以接收到响应的内容,但提交是无效的,没有任何效果。怎么回事?

------解决方案--------------------------------------------------------
firefox 装个firebug
看看你的提交和游览器提交有何区别

------解决方案--------------------------------------------------------
那就说明你提交的数据格式不对或者参数有错
  相关解决方案