I'm trying to submit a post form via c#. I've been browsing a lot of previous questions and i did not come to a working solution. I'd like to answer the following html form on a SSL url via C#:
<form action="/start/" method="post">
<input name="formtoken" type="hidden" value="SignupForm">
<input id="Email" name="Email" placeholder="Enter email address" type="text" value="">
<input autocomplete="off" id="Username" name="Username" placeholder="Enter username" type="text" value="">
<input autocomplete="off" id="Password" name="Password" placeholder="Enter password" type="password">
<input autocomplete="off" id="PasswordRetype" name="PasswordRetype" placeholder="Retype Password" type="password">
</form>
By modifying the following c# code which i found on another stackoverflow question:
static void Main(string[] args)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://url.com/start/");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
string postData = "formtoken=SignupForm&Email=sdfjsdfkhdsf2332@gmail.com?Username=test123?Password=testpw123?PasswordRetype=testpw123";
byte[] bytes = Encoding.UTF8.GetBytes(postData);
request.ContentLength = bytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.Length);
requestStream.Close();
WebResponse response = request.GetResponse();
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
var result = reader.ReadToEnd();
stream.Dispose();
reader.Dispose();
}
The result returns the previous page containing the form. I've checked the postData var to be correct by verifying it with a manual input via chromes network tool. I'm suspecting SSL has something to do with it, any ideas?
Thanks in advance