473,320 Members | 1,839 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,320 software developers and data experts.

How to read webpage in same session?

I'm using the following code to log into a webmail website. It logs me in
fine. I want to then get a particular message. However, I get this error:

Additional information: This property cannot be set after writing has
started.

on the line that I have noted below, which is this line
objRequest.ContentLength = strPost.Length

Any suggestions how I close the write and restart it?

Thanks,
Brett
Private Sub WebPage_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.rtxtShowWebpage.Text =
readHtmlPage("http://netmail.verizon.net/en_US/agent/moblogin")
End Sub
Function readHtmlPage(ByVal url As String) As String
Dim strResult As String = ""
'Dim strPost As String =
"page=/wam/in************************************@earthlink.n et&password=pass&saveuser=&locale=en_US&submit=sub mit"
'Dim strPost As String =
"passurl=http://www.comcast.net/&m**************************************@comcast.n et&passwd=123flash"
Dim strPost As String =
"js*********************************************** *************@verizon.net&PASSWORD=realmagnet1&Sub mit1=Log
In"
'Dim strPost As String =
"login_username=brettr&secretkey=realmagnet15&js_a utodetect_results=0&just_logged_in=1&submit=Login"
Dim myWriter As StreamWriter
Dim CookieContainer1 As New CookieContainer
Dim objRequest As HttpWebRequest = WebRequest.Create(url)

objRequest.Method = "POST"
objRequest.ContentLength = strPost.Length
objRequest.ContentType = "application/x-www-form-urlencoded"
objRequest.CookieContainer = CookieContainer1

Try
myWriter = New StreamWriter(objRequest.GetRequestStream())
myWriter.Write(strPost)
Catch e As Exception
Return e.Message
Finally
myWriter.Close()
End Try

Dim objResponse As System.Net.HttpWebResponse =
objRequest.GetResponse()
Dim sr As StreamReader
sr = New StreamReader(objResponse.GetResponseStream())
strResult = sr.ReadToEnd()

'Start next page request
objRequest.Create("http://netmail.verizon.net/en_US/cgi-bin/gx.cgi/AppLogic+mobmain")
objRequest.Method = "GET"
objRequest.ContentLength = strPost.Length <error occurs here>
objRequest.ContentType = "application/x-www-form-urlencoded"
objRequest.CookieContainer = CookieContainer1
objResponse = objRequest.GetResponse()

Try
myWriter = New StreamWriter(objRequest.GetRequestStream())
myWriter.Write("msgvw=INBOXMN382DELIM1092")
Catch e As Exception
Return e.Message
Finally
myWriter.Close()
End Try

objResponse = objRequest.GetResponse()
sr = New StreamReader(objResponse.GetResponseStream())
strResult = sr.ReadToEnd()

Return strResult
End Function

Nov 21 '05 #1
0 1122

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

Similar topics

8
by: Pete..... | last post by:
Hi all I am working on a log in script for my webpage. I have the username and the password stored in a PostgreSQL database. The first I do is I make a html form, where the user can type in his...
11
by: Markus Breuer | last post by:
I have a question about oracle commit and transactions. Following scenario: Process A performs a single sql-INSERT into a table and commits the transaction. Then he informs process B (ipc) to...
1
by: Kenneth Johansen | last post by:
Is there a way i can read xml from a webpage. The situation is that i have to type in an Url with some parameters (a login), when the page returns, it returns an ID that i have to use through...
2
by: swbaz | last post by:
What is an effect way to prevent users from viewing a webpage directly by typing in its URL? For example: If a default page is set up as a login screen with user name and password. The user...
1
by: Joseph Morales | last post by:
I'm trying to code a free-standing VBScript, executed by Windows Script Host on a client system, to push a button on an ASP .NET webpage that is hosted by another server. Note that the script is...
3
by: Dave Smithz | last post by:
Hi there, I have a website where users can log into. This users sessions as I believe most people use when implementing a login section of a website (each php page first checks a valid parameter...
3
by: Mike | last post by:
Hi, Upon login into my application I stored user data (userid, ...) in a cookie to be used throughout the application. One particular form is very complicated that uses AJAX and many AJAX...
7
by: =?Utf-8?B?SmVmZkRvdE5ldA==?= | last post by:
I have an asp.net application using a multi-page wizard control that grabs user selected files from a database and allows the user to configure parameters using controls on the wizard pages. The...
1
by: I Haas | last post by:
C#, .Net framework 1.1 visual studio 2003 From a aspx page I want to open the dialog box (download;save/open/cancel) I want to close the aspx page after the dialogbox opens. I open the dialog...
14
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I tried a google search but could not find anything. I am trying to cause one webpage to reload when a second web page is closed. The second webpage loads data into a session variable and when...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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: 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)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.