Connecting Tech Pros Worldwide Forums | Help | Site Map

POSTing a form programatically

Grey Alien
Guest
 
Posts: n/a
#1: Jul 12 '07
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

bruce barker
Guest
 
Posts: n/a
#2: Jul 12 '07

re: POSTing a form programatically


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)

Grey Alien wrote:
Quote:
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
Grey Alien
Guest
 
Posts: n/a
#3: Jul 12 '07

re: POSTing a form programatically


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.


bruce barker wrote:
Quote:
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)
>
Grey Alien wrote:
>
Quote:
>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
Closed Thread