learnerguy
Member
- Joined
- Jul 28, 2013
- Messages
- 20
- Programming Experience
- Beginner
Hi,
I want to be able to update an html file through my application. I get the source code of the website using webclient I tried to post the data once edited using the following I found on the net trying to figure out how to do this.(I am rather new at this stuff)
I then tell the program to post the info using
Where textbox2.text is the url the user entered and rtbdoc.text is the source of the html file.
I am not understanding, why is it not posting back the file?can someone please help me solve this. I am obviously doing it wrong
thanks a lot for your time
-Learnerguy
I want to be able to update an html file through my application. I get the source code of the website using webclient I tried to post the data once edited using the following I found on the net trying to figure out how to do this.(I am rather new at this stuff)
Function WDRequest(URL As String, method As String, POSTdata As String) As String Dim responseData As String = "" Try Dim hwrequest As Net.HttpWebRequest = Net.WebRequest.Create(TextBox2.Text) hwrequest.Accept = "*/*" hwrequest.AllowAutoRedirect = True hwrequest.UserAgent = "http_requester/0.1" hwrequest.Timeout = 60000 hwrequest.Method = method If hwrequest.Method = "POST" Then hwrequest.ContentType = "application/x-www-form-urlencoded" Dim encoding As New ASCIIEncoding() 'Use UTF8Encoding for XML requests Dim postByteArray() As Byte = encoding.GetBytes(POSTdata) hwrequest.ContentLength = postByteArray.Length Dim postStream As IO.Stream = hwrequest.GetRequestStream() postStream.Write(postByteArray, 0, postByteArray.Length) postStream.Close() End If Dim hwresponse As Net.HttpWebResponse = hwrequest.GetResponse() If hwresponse.StatusCode = Net.HttpStatusCode.OK Then Dim responseStream As IO.StreamReader = _ New IO.StreamReader(hwresponse.GetResponseStream()) responseData = responseStream.ReadToEnd() End If hwresponse.Close() Catch ex As Exception responseData = "An error occurred: " & ex.Message End Try Return responseData End Function
I then tell the program to post the info using
WDRequest("textbox2.text", "POST", "rtbdoc.text")
Where textbox2.text is the url the user entered and rtbdoc.text is the source of the html file.
I am not understanding, why is it not posting back the file?can someone please help me solve this. I am obviously doing it wrong
thanks a lot for your time
-Learnerguy
Last edited by a moderator: