The page I would like to interact with has the following inputs when I view the source:
<form action="/index.php" method="post">
<input type="hidden" name="ac" value="raubzug">
<input type="hidden" name="sac" value="attack">
<input type="hidden" name="gegnerid" value="115021541">
<input type="image" src="img/lang/EN/btn_angriff.jpg">
So, instead of clicking on the button that is this page I want to automate it through vb.net. From what I have read, I need to use teh webRequest object set to POST. However, when I try to run my application I get the following error on the line where I declare my StreamWriter:
"An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: Stream was not writable."
Here is my code:
Can anyone help me? I am not sure what I am doing wrong... I have tried a few different approaches now.
Thanks,
zoop
<form action="/index.php" method="post">
<input type="hidden" name="ac" value="raubzug">
<input type="hidden" name="sac" value="attack">
<input type="hidden" name="gegnerid" value="115021541">
<input type="image" src="img/lang/EN/btn_angriff.jpg">
So, instead of clicking on the button that is this page I want to automate it through vb.net. From what I have read, I need to use teh webRequest object set to POST. However, when I try to run my application I get the following error on the line where I declare my StreamWriter:
"An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: Stream was not writable."
Here is my code:
VB.NET:
Private Sub hitPlayerAlt(ByVal strPlayerID As String)
Dim postData As String
postData = "ac=raubzug&sac=attack&gegnerid=" & strPlayerID
Dim request As WebRequest = WebRequest.Create("http://world5.knightfight.co.uk/index.php?ac=raubzug")
request.Method = "POST"
request.ContentType = "application/x-www-form-encoded"
''// Send the Post Data
Dim sw As StreamWriter = New StreamWriter(request.GetRequestStream)
sw.WriteLine(postData)
''// Read the Response
Dim wr As WebResponse = request.GetResponse
Dim sr As StreamReader = New StreamReader(wr.GetResponseStream)
Dim responseText As String = sr.ReadToEnd
End Sub
Can anyone help me? I am not sure what I am doing wrong... I have tried a few different approaches now.
Thanks,
zoop