Login to website programically

vinnie881

Well-known member
Joined
Sep 3, 2006
Messages
152
Programming Experience
3-5
I have the following website. I am trying to log in via vb.net by sending the post data (not simulating the button click). Is this possible since there are two submit buttons, and a view state that is generated?
I have spent way too longon this. This is a very difficult question in my opinion, but if your good with ASP.net websites, and can assist, I would greatly appriciate it.



HTML:
<html>
<head>
<link href='/IssueTracker/styles/styles.css' type="text/css" rel="stylesheet">
<title>Issue Tracker - Login</title>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0" background='/IssueTracker/images/bars.gif'>
<tr>
<td><img src='/IssueTracker/images/ASP.NET-Logo-small.gif' width="76" height="47" style="margin-left:10px;margin-right:10px;margin-bottom:2px" alt="ASP.NET Starter Kit"/></td>
<td style="vertical-align:bottom">
 
</td>
<td width="100%" valign="bottom">
<table width="100%">
<tr>
<td align="center" valign="bottom">
<img src='/IssueTracker/images/IssueTracker.gif' width="325" height="18" alt=""/>
</td>
<td valign="bottom"></td>
</tr>
</table>
</td>
</tr>
</table>
<table class="bodyTable">
<tr>
<td class="bodyCell">
<form name="_ctl0" method="post" action="DesktopDefault.aspx" id="_ctl0">
<input type="hidden" name="__VIEWSTATE" value="dDwtMTYxMjUzNzIxNjs7bDxjaGtSZW1lbWJlcjs+Pn9lcN3KeQZglu2C3cNfqX0rEhKh" />
<table class="contentTable">
<tr>
<td class="contentCell">
<table cellpadding="4" cellspacing="0">
<tr>
<td height="20">
<h1>Account Login</h1>
</td>
</tr>
<tr>
<td>
<span id="lblError"><font color="Red"></font></span>
</td>
</tr>
<tr>
<td>
Username:
 
</td>
</tr>
<tr>
<td>
<input name="txtUsername" type="text" id="txtUsername" />
</td>
</tr>
<tr>
<td>
Password:
 
</td>
</tr>
<TR>
<td>
<input name="txtPassword" type="password" id="txtPassword" />
</td>
</TR>
<tr>
<td>
<span class="normal"><input id="chkRemember" type="checkbox" name="chkRemember" /><label for="chkRemember">Remember Login</label></span>
</td>
</tr>
<tr>
<td>
<input type="submit" name="btnLogin" value="sign-in" onclick="if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); " language="javascript" id="btnLogin" />
 
<input type="submit" name="btnRegister" value="register" id="btnRegister" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
 
Last edited by a moderator:
Ok, it looks to me like the __VIEWSTATE input is a session key that is probably going to be different every time so to login successfully you will need to pass this session key along with all the other input fields on the form.

This can still all be automated without simulating clicks, to do this you will first need to make a http request for this page to recieve a valid session key, then you will have to parse the html from this request to get the key as a string you can use later.

After that you will need to make another request to DesktopDefault.aspx (the target of the login form) and you will have to pass all the input names and variables along as part of the query string, or as part of your post data.

for example...
http://www.websitename.com/DesktopDefault.aspx?__VIEWSTATE=dDwtMTYxMjUzNzIxNjs7bDxjaGtSZW1lbWJlcjs+Pn9lcN3KeQZglu2C3cNfqX0rEhKh&txtUsername=usernamehere&txtPassword=passwordhere&chkRemember=0

where viewstate is actualy the string you got earlier.
 
Back
Top