Dim strPost As String
Dim Url As String = "http://10.10.7.8/WebApplication1/WebForm1.aspx "
Dim objRequest As HttpWebRequest
Try
objRequest = CType(WebRequest.Create(Url), HttpWebRequest)
Catch ex As Exception
MsgBox( "Create WebRequest Errer ")
Return "fault "
End Try
Dim encoding As Encoding = encoding.GetEncoding( "UTF-8 ")
Dim data As Byte() = encoding.GetBytes(strPost)
objRequest.Method = "POST "
objRequest.ContentLength = data.Length
objRequest.ContentType = "application/x-www-form-urlencoded "
Dim newStream As Stream
Try
////////////////////////////////////////////////////////////////
newStream = objRequest.GetRequestStream
////////////////////////////////////////////////////////////////
newStream.Write(data, 0, data.Length)
newStream.Close()
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
在一个数据集循环中调用上述过程,第一次正确,第二条运行到//框住的newStream = objRequest.GetRequestStream出错,这是什么原因?
会不会是病毒引起,最近网络异常,打开网页常在第一行出现一行链接其它页面的链接
Dim objResponse As HttpWebResponse
Try
objResponse = CType(objRequest.GetResponse(), HttpWebResponse)
sr = New StreamReader(objResponse.GetResponseStream())
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
sr所读的内容也是加了这一行。有什么办法可以避免这种情况。
------解决方案--------------------------------------------------------