POSTing a form programatically

G

Grey Alien

I am trying to programatically POST an ASP form, to allow me to log on
to a site programatically.

<form name="aspnetForm" method="post" action="Default.aspx"
id="aspnetForm">
<input name="_ct99:Content:UsrName" type="text"
id="_ct99_Content_UsrName" />
<input name="_ct99:Content:pwd" type="password"
id="_ct99_Content_Pwd" />
<input type="submit" name="_ct99:Content:btnLogon" value="Logon"
id="_ct99_Content_btnLogon" />
<input id="_ct99_Content_SavePwd" type="checkbox"
name="_ct99:Content:SavePwd" /></p>
</form>


What I find strange/confusing is that the name attribute of the elements
(i.e. the controls) are not 'legal' (i.e. they contain colons etc).

I need the 'name'='value' pairs to use in the POST.

I am using an external library (cURL) to do the POST action, so far I
have failed to log on when using either the name attribute (looked
suspicious anyway), but I also failed to log on when I used the id
attribute.

The "problem" definitely lies with this ASP.Net page, since I have
successfully logged on other pages using the post method.

Any ideas/suggestions (or preferably solutions) would be most welcome
 
B

bruce barker

asp.net 1.1 used illegal names (so does asp.net 2.0, but its only the
breaking the first letter rule by using an "_", it replaced ":" with "$").

if this is a asp.net site, you need to also send the __VIEWSTATE with
the post. you can not hard code this. you must do a get, and parse the
html to get a valid _VIEWSTATE to send with the post. depending on how
the page was written, you may need to send _EVENTTARGET (say the login
is a link button).

-- bruce (sqlwork.com)
 
G

Grey Alien

Top posting (to be consistent)

Bruce, I think this is definitetly the way to go. I've been sniffing the
data sent between the browser and the server, and I am missing the
fields you mentioned.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top