- Impact
- 11
Im trying to post data from a VB.NET application to a web form, but its not passing the fields (it is doing a posting request)
Not all the code, just the code applicable to the problem.
Any ideas?
Not all the code, just the code applicable to the problem.
Code:
Public Client As New System.Net.WebClient
Public Function HTTPRequest(ByVal URL As String, ByVal postString As String, Optional ByVal Method As String = "POST") As String
Dim serverResponse() As Byte
Dim postBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(postString)
Try
serverResponse = Me.Client.UploadData(URL, Method, postBytes)
' Gets data from server!
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, ex.Source & " Error")
Exit Function
End Try
Dim responseHTML As String = (System.Text.Encoding.ASCII.GetString(serverResponse))
' Turns server response(in bytes) into a string(HTML)
Return responseHTML
End Function
'Execute function code
Dim postStr As String = "type=100"
Dim submiturl As String = "http://127.0.0.1/posting.php"
response = HTTPRequest(submiturl, postStr)
Any ideas?