I am looking to figure out how to post data into a java login form from C# in order to get to a page behind it and the data there. Here is my starting code:
This gets me to the login page which holds the following:
body text="#000000" onLoad="document.forms[0].username.focus(); document.forms[0].username.select();" bgcolor="#FFFFFFFF"> <form method="post" action="/names.nsf?Login"><table border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"><tr><td width="100"> </td><td><h1>Server
Login</h1>Please type your user name and password<br></td><td width="100"> </td></tr> <tr><td height="20" colspan="3"> </td></tr> <tr><td width="100" align="right"> User name: </td><td><input type="text" size="20" maxlength="256"
name="username"></td><td> </td></tr> <tr><td width="100" align="right">Password: </td><td><input type="password" size="20" maxlength="256" name="password"><input type="hidden" name="redirectto" value="/SEelementary.nsf/0/8583D800B0150EBD852574C20065A45E?OpenDocument"></td><td> </td></tr>
<tr><td height="20" colspan="3"> </td></tr> <tr><td width="100"> </td><td><input type="submit" value="Log In"></td><td> </td></tr> <tr><td height="20" colspan="3"> </td></tr>
What I want to do is post to this page to login (fill the username and password inputs, and hit the button) and return the html that is on the next page. I tried request.Credentials, but it doesnt work for this type of authentication. I dont understand
how to send the post.. can someone fill in the post code for me and give me any other tips.. I know cookies might be an issue too and I do have some information on how to save cookies if so...
triley35
0 Points
1 Post
Httpwebrequest - and Posting to java form
Sep 15, 2008 06:43 PM|LINK
I am looking to figure out how to post data into a java login form from C# in order to get to a page behind it and the data there. Here is my starting code:
_____________________________________
string url = "https://harmony.danville.k12.in.us/SEelementary.nsf/0/8583D800B0150EBD852574C20065A45E?OpenDocument"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Encoding enc = Encoding.GetEncoding(1252); StreamReader responseStream = new StreamReader(response.GetResponseStream(), enc); string html = responseStream.ReadToEnd(); Console.WriteLine(html);response.Close();
responseStream.Close();
___________________________________________
This gets me to the login page which holds the following:
body text="#000000" onLoad="document.forms[0].username.focus(); document.forms[0].username.select();" bgcolor="#FFFFFFFF"> <form method="post" action="/names.nsf?Login"><table border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC"><tr><td width="100"> </td><td><h1>Server Login</h1>Please type your user name and password<br></td><td width="100"> </td></tr> <tr><td height="20" colspan="3"> </td></tr> <tr><td width="100" align="right"> User name: </td><td><input type="text" size="20" maxlength="256" name="username"></td><td> </td></tr> <tr><td width="100" align="right">Password: </td><td><input type="password" size="20" maxlength="256" name="password"><input type="hidden" name="redirectto" value="/SEelementary.nsf/0/8583D800B0150EBD852574C20065A45E?OpenDocument"></td><td> </td></tr> <tr><td height="20" colspan="3"> </td></tr> <tr><td width="100"> </td><td><input type="submit" value="Log In"></td><td> </td></tr> <tr><td height="20" colspan="3"> </td></tr>
What I want to do is post to this page to login (fill the username and password inputs, and hit the button) and return the html that is on the next page. I tried request.Credentials, but it doesnt work for this type of authentication. I dont understand how to send the post.. can someone fill in the post code for me and give me any other tips.. I know cookies might be an issue too and I do have some information on how to save cookies if so...
Thanks for any help!!!