473,324 Members | 2,268 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Can't login via POST?

I'm trying three different methods for logging into a webmail account. In
Post1() and Post2(), I always get back the login page. Not the page after
logging in. On TryCookies(), I'm not sure. It will run but there are some
other things that need to take place. Any suggestion on what is wrong with
the Post1() and Post2() or how to get TryCookies() going? Any other
guidance is appreciated.

Private Sub TryCookies()
Dim uri As New
Uri("http://netmail.verizon.net/en_US/agent/mo************************@verizon.net&password=so mepassword&jsCapable=1&frames=0&LOCALE=en_US&VARIA NT=")
Dim cookieUri As New Uri("http://netmail.verizon.net")
Dim request As System.Net.HttpWebRequest
Dim response As System.Net.HttpWebResponse
request = CType(System.Net.WebRequest.Create(uri),
System.Net.HttpWebRequest)
request.CookieContainer = New System.Net.CookieContainer
request.CookieContainer.SetCookies(cookieUri,
"ABCD=G7789Ooqdowjkc7rrFA28r5hp0f78e")
'Me.rtxtShowWebpage.Text = response.ContentEncoding()
End Sub

Private Sub Post2()

Dim encoding As New ASCIIEncoding
' Use the appropriate HTML field names to stuff into the post header
Dim PostData As String =
"?u****************@verizon.net&password=somepassw ord&jsCapable=1&frames=0&LOCALE=en_US&VARIANT="
Dim Data() As Byte = encoding.GetBytes(PostData)
'Dim Cookies As New CookieContainer

' Initialise the request
Dim LoginReq As System.Net.HttpWebRequest =
System.Net.WebRequest.Create("http://netmail.verizon.net/en_US/agent/moblogin")
With LoginReq
.KeepAlive = False
.Method = "POST"
' Note: if the page uses a redirect if will fail (see below)
.AllowAutoRedirect = False
.ContentType = "application/x-www-form-urlencoded"
.ContentLength = Data.Length
End With

' Add the POST data
Dim SendReq As Stream = LoginReq.GetRequestStream
SendReq.Write(Data, 0, Data.Length)
SendReq.Close()

' Obtain the response
Dim LoginRes As System.Net.HttpWebResponse = LoginReq.GetResponse()
Dim sReader As StreamReader = New
StreamReader(LoginRes.GetResponseStream)
Dim HTML As String = sReader.ReadToEnd
Me.rtxtShowWebpage.Text = HTML
End Sub

Private Sub Post1()
Dim wrq As System.Net.WebRequest = _
System.Net.WebRequest.Create("http://netmail.verizon.net/en_US/agent/moblogin")
wrq.Credentials = New System.Net.NetworkCredential("us**@verizon.net",
"somepassword")
Dim wrp As System.Net.WebResponse = wrq.GetResponse()
Dim sr As New StreamReader(wrp.GetResponseStream())
'MessageBox.Show(sr.ReadToEnd())
Me.rtxtShowWebpage.Text = sr.ReadToEnd
sr.Close()
wrp.Close()

Dim myclient As System.Net.WebClient = New System.Net.WebClient
Dim bufData As Byte()
Dim firstLevelbufData As String
bufData = myclient.DownloadData("http://www.microsoft.com")
' got the bufData now convert it into string format
' firstLevelbufData is a string variable
firstLevelbufData = Encoding.Default.GetString(bufData)
End Sub
Thanks,
Brett
Nov 21 '05 #1
0 1356

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Gill Bates | last post by:
I'm trying to login to a banking site (https://www.providentconnection.com) using vb.net. I've tried many variations of WebClient and HttpWebRequest; none of which I've got to work. My latest...
1
by: Brian | last post by:
Hello All, I need some help for my auto-post C# program. I tried to post something on my forum, but my forum need me to login first. How could I keep the session information in two http...
14
by: n8 | last post by:
Hi, Hi have to do the followign and have been racking my brain with various solutions that have had no so great results. I want to use the System.Net.WebClient to submit data to a form (log a...
3
by: bill | last post by:
I need to open a asp.net web form from a classic asp page, and pass a username and password to the asp.net page. The username and password exist as session variables in the classic asp...
8
by: chris_fieldhouse | last post by:
Hi fairly new to php, but picking it up quite well. the question I have, is it possible for a php script which is used to validate values submitted in a form, to then post these values onto...
1
by: EricRybarczyk | last post by:
I am starting a rewrite of an existing Classic ASP web site in ASP.NET 2.0. The existing ASP application has several types of users, each with a separate login process (separate login page,...
0
by: nfhm2k | last post by:
I've been trying to find a solution to this for quite some time now... I even took a look at existing scripts... Including this one......
4
by: rpapaiof | last post by:
i have designed a login page in this form <?php if ( $_POST && $_POST && $_POST) { $a=file("file.txt"); foreach($a as $k => $v) { $b=trim($v); } #echo "<pre>"; print_r($b); echo "</pre>";...
0
by: barrybevel | last post by:
Hi, I'm trying to login to the www.vodafone.ie website using HttpWebRequest. It works fine with IE/Firefox and the .NET Web Control too, just not with my code. I think it's a redirect 302...
5
by: mcfly1204 | last post by:
I am attempting to use WebRequest to access a page that requires a login/password to access. My last WebRequest continues to timeout. Any help or thoughts would be appreciated. namespace...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.