VB.net Webbrowser Navigate Post的数据中有& 如何处理
Post的数据中有&如何处理
现在的代码
Public Function Postdata(ByVal url As String, ByVal postda() As String)
Dim post As String = ""
For Each s In postda
post += s + "&"
Next
post = post.Substring(0, post.Length - 1)
Dim bytearray() As Byte
Dim leng = utf8_without_bom.GetByteCount(post)
ReDim bytearray(leng - 1)
bytearray = utf8_without_bom.GetBytes(post)
Dim send As Object = bytearray
Dim vHeaders As Object
'vHeaders = "Content-Type: application/x-www-form-urlencoded" + Chr(10) + Chr(13) + "pragma: no-cache" + Chr(10) + Chr(13) + "Cache-Control: no-store, must-revalidate" _
' + Chr(10) + Chr(13) + "expires: Wed, 26 Feb 1997 08:21:57 GMT" + Chr(10) + Chr(13) + "expires : 0" + Chr(10) + Chr(13) + "User-Agent:Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)"
'Web_SendUsed.Navigate(url + "?reserveidforcache=" & postda(0) & postda(7), "_self", send, vHeaders)
vHeaders = "Content-Type: application/x-www-form-urlencoded"
Web_SendUsed.Navigate(url + "?reserveidforcache=" & postda(0) & postda(7), "_self", send, vHeaders)
End Function
如果这样写,那么数据中有&会出错。因为&是连接两个的字符。
问如何修改
一些变量的定义:
Public utf8_without_bom As System.Text.UTF8Encoding = New System.Text.UTF8Encoding(False)
Public RequestUrl As String
Public SendUrl As String