Solved

HttpWebRequest Form Authentication Not Getting Past Login Page

Posted on 2010-08-19
2
665 Views
Last Modified: 2012-05-10
Hello,

I am trying to use the POST method with a HttpWebRequest object while passing in real login credentials and am failing to get past the login page. (The credentials down there are real, but not mine personally =D)

I got the same code to work for Totsy.com but cannot get it to work for Zulily.com.

Any help in getting past the login page so I can retrieve the after login page would be much appreciated.

Thanks,
Mohammed
Dim strUrl As String = "https://www.zulily.com/index.php/customer/account/login/"

ServicePointManager.Expect100Continue = False
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3

Dim webRequest As HttpWebRequest
Dim responseReader As StreamReader
Dim responseData As String
Dim postData As String = "email=experttest@hotmail.com&pass=pass1234"
Dim cookies As CookieContainer = New CookieContainer()
Dim requestWriter As StreamWriter

'post form data to page
webRequest = HttpWebRequest.Create(strUrl)
webRequest.Method = WebRequestMethods.Http.Post
webRequest.ContentType = "application/x-www-form-urlencoded"
webRequest.CookieContainer = cookies
webRequest.ContentLength = postData.Length

requestWriter = New StreamWriter(webRequest.GetRequestStream)
requestWriter.Write(postData)
requestWriter.Close()

'recieve cookie
webRequest.GetResponse().Close()

'now we send the cookie
webRequest = HttpWebRequest.Create("http://www.zulily.com/index.php/")
webRequest.CookieContainer = cookies
responseReader = New StreamReader(webRequest.GetResponse.GetResponseStream())
responseData = responseReader.ReadToEnd()
responseReader.Close()

SpillLabel.Text = Server.HtmlEncode(responseData)

Open in new window

0
Comment
Question by:mohali786
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 28

Accepted Solution

by:
sybe earned 500 total points
ID: 33475685
0
 

Author Comment

by:mohali786
ID: 33480473
500 points for you man! How did I mis that? Thanks Sybe! =D
0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question