WebConversation missing session data
"Burt Carter" <[email protected]> Thu, 03 Dec 2009 13:03:49 -0500
| Newsgroups | gmane.comp.web.httpunit.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello everyone,
I hope this is the correct place to ask this question. I am having trouble logging into a website via httpunit. The website is maintained / created by me. Once the login.aspx page authenticates the user, it creates a session variable that holds the user's profile. For some reason I am not being redirected to the default.aspx page after successful authentication. Here's my code:
WebConversation conversation = new WebConversation();
HttpUnitOptions.setLoggingHttpHeaders(true);
ClientProperties cltprops = conversation.getClientProperties();
cltprops.setUserAgent("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/HTTPUnit");
cltprops.setAcceptGzip(false);
cltprops.setAutoRedirect(true);
cltprops.setAcceptCookies(true);
cltprops.setAutoRefresh( true );
// go to login, successful authentication should redirect to default.aspx
WebRequest index_request = new GetMethodWebRequest("http://helpdesk.jchs.com/login.aspx");
WebResponse index_response = conversation.getResponse(index_request);
WebForm loginForm = index_response.getForms()[0];
loginForm.setParameter( "ctl00$ContentPlaceHolder1$txtUser", "username" );
loginForm.setParameter( "ctl00$ContentPlaceHolder1$txtPass", "password" );
loginForm.submit();
I get the following from debug:
Connecting to helpdesk.jchs.com
Sending:: GET http://helpdesk.jchs.com/login.aspx
Sending:: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/HTTPUnit
Received from http://helpdesk.jchs.com/login.aspx
Header:: HTTP/1.1 200 OK
Header:: Date: Thu, 03 Dec 2009 18:02:03 GMT
Header:: Server: Microsoft-IIS/6.0
Header:: X-Powered-By: ASP.NET
Header:: X-AspNet-Version: 2.0.50727
Header:: Cache-Control: private
Header:: Content-Type: text/html; charset=utf-8
Header:: Content-Length: 3805
Connecting to helpdesk.jchs.com
Sending:: POST login.aspx
Sending:: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/HTTPUnit
Sending:: Referer: http://helpdesk.jchs.com/login.aspx
Sending:: Content-Type: application/x-www-form-urlencoded
Received from http://helpdesk.jchs.com/login.aspx
Header:: HTTP/1.1 302 Found
Header:: Date: Thu, 03 Dec 2009 18:02:03 GMT
Header:: Server: Microsoft-IIS/6.0
Header:: X-Powered-By: ASP.NET
Header:: X-AspNet-Version: 2.0.50727
Header:: Location: /Default.aspx
Header:: Set-Cookie: ASP.NET_SessionId=q4rrhcju0i0ozq55co3z1cr1; path=/; HttpOnly
Header:: Set-Cookie: .ASPXAUTH=3C3AB9D9A392EAA4A4E13661487C8706C3B8DFAAA11E5C70FF2E6852B32F3476BA658A2D5C8DAEA8B0B4B76432B3B617D0DEDA0B955C3DDCEFC1FF2C15D49792A20BCB6F1FC0E704FA186082542C1590; path=/; HttpOnly
Header:: Cache-Control: private
Header:: Content-Type: text/html; charset=utf-8
Header:: Content-Length: 132
Connecting to helpdesk.jchs.com
Sending:: GET /Default.aspx
Sending:: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/HTTPUnit
Sending:: Referer: http://helpdesk.jchs.com/login.aspx
Received from http://helpdesk.jchs.com/Default.aspx
Header:: HTTP/1.1 302 Found
Header:: Date: Thu, 03 Dec 2009 18:02:03 GMT
Header:: Server: Microsoft-IIS/6.0
Header:: X-Powered-By: ASP.NET
Header:: X-AspNet-Version: 2.0.50727
Header:: Location: /login.aspx
Header:: Cache-Control: private
Header:: Content-Type: text/html; charset=utf-8
Header:: Content-Length: 130
Connecting to helpdesk.jchs.com
Sending:: GET /login.aspx
Sending:: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/HTTPUnit
Sending:: Referer: http://helpdesk.jchs.com/login.aspx
Received from http://helpdesk.jchs.com/login.aspx
Header:: HTTP/1.1 200 OK
Header:: Date: Thu, 03 Dec 2009 18:02:03 GMT
Header:: Server: Microsoft-IIS/6.0
Header:: X-Powered-By: ASP.NET
Header:: X-AspNet-Version: 2.0.50727
Header:: Cache-Control: private
Header:: Content-Type: text/html; charset=utf-8
Header:: Content-Length: 3805
Connecting to helpdesk.jchs.com
Sending:: POST login.aspx
Sending:: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/HTTPUnit
Sending:: Referer: http://helpdesk.jchs.com/login.aspx
Sending:: Content-Type: application/x-www-form-urlencoded
Received from http://helpdesk.jchs.com/login.aspx
Header:: HTTP/1.1 302 Found
Header:: Date: Thu, 03 Dec 2009 18:02:03 GMT
Header:: Server: Microsoft-IIS/6.0
Header:: X-Powered-By: ASP.NET
Header:: X-AspNet-Version: 2.0.50727
Header:: Location: /Default.aspx
Header:: Set-Cookie: ASP.NET_SessionId=ifnucv55nvthb345reh1wujj; path=/; HttpOnly
Header:: Set-Cookie: .ASPXAUTH=3FC5624FD6A6FBEAC5F0B0059B38F9DC5DACB08FDD803D73E23A881325BFA602B5F651004E64F9AA764246369A4C4F3200E8A8E75199D451F7494AB746A46A2E87533800BACE0B58AC46FD7963E8F55A; path=/; HttpOnly
Header:: Cache-Control: private
Header:: Content-Type: text/html; charset=utf-8
Header:: Content-Length: 132
Connecting to helpdesk.jchs.com
Sending:: GET /Default.aspx
Sending:: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/HTTPUnit
Sending:: Referer: http://helpdesk.jchs.com/login.aspx
Received from http://helpdesk.jchs.com/Default.aspx
Header:: HTTP/1.1 302 Found
Header:: Date: Thu, 03 Dec 2009 18:02:03 GMT
Header:: Server: Microsoft-IIS/6.0
Header:: X-Powered-By: ASP.NET
Header:: X-AspNet-Version: 2.0.50727
Header:: Location: /login.aspx
Header:: Cache-Control: private
Header:: Content-Type: text/html; charset=utf-8
Header:: Content-Length: 130
Connecting to helpdesk.jchs.com
Sending:: GET /login.aspx
Sending:: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/HTTPUnit
Sending:: Referer: http://helpdesk.jchs.com/login.aspx
Received from http://helpdesk.jchs.com/login.aspx
Header:: HTTP/1.1 200 OK
Header:: Date: Thu, 03 Dec 2009 18:02:03 GMT
Header:: Server: Microsoft-IIS/6.0
Header:: X-Powered-By: ASP.NET
Header:: X-AspNet-Version: 2.0.50727
Header:: Cache-Control: private
Header:: Content-Type: text/html; charset=utf-8
Header:: Content-Length: 3805
When I print out: conversation.getCurrentPage().getText() , I receive the login page's html.
Any help would be greatly appreciated.
- Burt
Burt Carter
MCNE, MCSA, RHCT, MISM
Technology Director
Jenkins County School System
This e-mail message and all attachments transmitted with it may contain
legally privileged and confidential information intended solely for the
use of the addressee. If the reader of this message is not the intended
recipient, you are hereby notified that any reading, dissemination,
distribution, copying, or other use of this message or its attachments
is strictly prohibited. If you have received this message in error,
please notify the sender immediately by telephone (478-982-6000) or by
electronic mail, and delete this message and all copies and backups
thereof. Thank You.
------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing.
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev