By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,694 Members | 1,313 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,694 IT Pros & Developers. It's quick & easy.

http download & cookies

P: n/a
I have this problem.
I have to download a document from a web site in specified intervals of time
and save it to hdd.
The problem is that before I get to document I have to login to site by a
web form authentication.
The login form have an option to remember by login by storing a cookie on my
PC.
The question is may I somehow use this saved cookie in my VB app to get the
document, or is there a way to fill the login details in the login form?

TIA
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi,

Here is an example on how to download a file from a windows form.
You will need to add a webrequest.credentials to automatically logon to the
site.

http://msdn.microsoft.com/library/de...tialstopic.asp
Dim request As WebRequest

Dim response As WebResponse

Dim reader As Stream

Dim writer As Stream

Dim data(1023) As Byte

Dim count As Integer

Dim total As Integer

Me.Show()

Me.Text = "Downloading file ....."

Application.DoEvents()

request =
WebRequest.Create("http://www.onteorasoftware.com/downloads/multigrids.zip")

response = request.GetResponse()

reader = response.GetResponseStream()

ProgressBar1.Maximum = CInt(response.ContentLength)

ProgressBar1.Value = 0

total = 0

writer = File.Create("mylocaldata.zip")

While True

count = reader.Read(data, 0, 1024)

If count <= 0 Then

Exit While

End If

writer.Write(data, 0, count)

total += 1024

If total < ProgressBar1.Maximum Then ProgressBar1.Value = total

Application.DoEvents()

End While

reader.Close()

writer.Close()

Ken

--------------------------

"Nikolay Petrov" <jo******@mail.bg> wrote in message
news:uT**************@TK2MSFTNGP15.phx.gbl...
I have this problem.
I have to download a document from a web site in specified intervals of time
and save it to hdd.
The problem is that before I get to document I have to login to site by a
web form authentication.
The login form have an option to remember by login by storing a cookie on my
PC.
The question is may I somehow use this saved cookie in my VB app to get the
document, or is there a way to fill the login details in the login form?

TIA

Nov 21 '05 #2

P: n/a
I can't use webrequest.credentials because the login process is made as a
login form, can I?
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:OO**************@TK2MSFTNGP10.phx.gbl...
Hi,

Here is an example on how to download a file from a windows form.
You will need to add a webrequest.credentials to automatically logon to
the
site.

http://msdn.microsoft.com/library/de...tialstopic.asp
Dim request As WebRequest

Dim response As WebResponse

Dim reader As Stream

Dim writer As Stream

Dim data(1023) As Byte

Dim count As Integer

Dim total As Integer

Me.Show()

Me.Text = "Downloading file ....."

Application.DoEvents()

request =
WebRequest.Create("http://www.onteorasoftware.com/downloads/multigrids.zip")

response = request.GetResponse()

reader = response.GetResponseStream()

ProgressBar1.Maximum = CInt(response.ContentLength)

ProgressBar1.Value = 0

total = 0

writer = File.Create("mylocaldata.zip")

While True

count = reader.Read(data, 0, 1024)

If count <= 0 Then

Exit While

End If

writer.Write(data, 0, count)

total += 1024

If total < ProgressBar1.Maximum Then ProgressBar1.Value = total

Application.DoEvents()

End While

reader.Close()

writer.Close()

Ken

--------------------------

"Nikolay Petrov" <jo******@mail.bg> wrote in message
news:uT**************@TK2MSFTNGP15.phx.gbl...
I have this problem.
I have to download a document from a web site in specified intervals of
time
and save it to hdd.
The problem is that before I get to document I have to login to site by a
web form authentication.
The login form have an option to remember by login by storing a cookie on
my
PC.
The question is may I somehow use this saved cookie in my VB app to get
the
document, or is there a way to fill the login details in the login form?

TIA

Nov 21 '05 #3

P: n/a
Hi,

Thats what it is for

Ken
------------------
"Nikolay Petrov" <jo******@mail.bg> wrote in message
news:uH**************@TK2MSFTNGP09.phx.gbl...
I can't use webrequest.credentials because the login process is made as a
login form, can I?
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:OO**************@TK2MSFTNGP10.phx.gbl...
Hi,

Here is an example on how to download a file from a windows form.
You will need to add a webrequest.credentials to automatically logon to
the
site.

http://msdn.microsoft.com/library/de...tialstopic.asp
Dim request As WebRequest

Dim response As WebResponse

Dim reader As Stream

Dim writer As Stream

Dim data(1023) As Byte

Dim count As Integer

Dim total As Integer

Me.Show()

Me.Text = "Downloading file ....."

Application.DoEvents()

request =
WebRequest.Create("http://www.onteorasoftware.com/downloads/multigrids.zip")

response = request.GetResponse()

reader = response.GetResponseStream()

ProgressBar1.Maximum = CInt(response.ContentLength)

ProgressBar1.Value = 0

total = 0

writer = File.Create("mylocaldata.zip")

While True

count = reader.Read(data, 0, 1024)

If count <= 0 Then

Exit While

End If

writer.Write(data, 0, count)

total += 1024

If total < ProgressBar1.Maximum Then ProgressBar1.Value = total

Application.DoEvents()

End While

reader.Close()

writer.Close()

Ken

--------------------------

"Nikolay Petrov" <jo******@mail.bg> wrote in message
news:uT**************@TK2MSFTNGP15.phx.gbl...
I have this problem.
I have to download a document from a web site in specified intervals of
time
and save it to hdd.
The problem is that before I get to document I have to login to site by a
web form authentication.
The login form have an option to remember by login by storing a cookie on
my
PC.
The question is may I somehow use this saved cookie in my VB app to get
the
document, or is there a way to fill the login details in the login form?

TIA


Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.