这里暂时没有写到对http数据头的定义
当然头的定义可以这样写
Dim
head
As
WebHeaderCollection
head.Add( " name " , " value " )
send.Headers = head
head.Add( " name " , " value " )
send.Headers = head
好了,归到正题,下面是类,接收到的是一个stream,这样方便利用哈!
Imports
System.Net
Imports System.io
Public Class http Class http
Public Function httpsend()Function httpsend(ByVal uri As String, ByVal method As String, ByVal content As String) As Stream
Dim send As WebRequest = WebRequest.Create(uri)
send.Method = method
Dim postdata As Byte()
postdata = System.Text.Encoding.Default.GetBytes(content)
send.ContentLength = postdata.Length
Dim postStream As Stream = send.GetRequestStream()
postStream.Write(postdata, 0, postdata.Length)
postStream.Close()
Dim re As WebResponse = send.GetResponse
Return re.GetResponseStream
End Function
End Class
Imports System.io
Public Class http Class http
Public Function httpsend()Function httpsend(ByVal uri As String, ByVal method As String, ByVal content As String) As Stream
Dim send As WebRequest = WebRequest.Create(uri)
send.Method = method
Dim postdata As Byte()
postdata = System.Text.Encoding.Default.GetBytes(content)
send.ContentLength = postdata.Length
Dim postStream As Stream = send.GetRequestStream()
postStream.Write(postdata, 0, postdata.Length)
postStream.Close()
Dim re As WebResponse = send.GetResponse
Return re.GetResponseStream
End Function
End Class
对应的接收页面可以在LOAD事件里这样写
If
Not
IsDBNull
(Request)
Then
Dim a As Stream = Request.InputStream
end if
Dim a As Stream = Request.InputStream
end if