954,549 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to download file (from a SSL web) that requires login id to the page using vb.net

Hi guys,

as per title above,
im at my wits end after a week of thoughts....
i want to download a file from a SSL web to my local(C:\)

e.g https://www.abc.com/File/myfile.txt

Scenario:
from the web browser(Internet Explorer), i required to login to the site in order to download the file.

in the vb program i pass in this url to download the file (include my password and username):
https://www.abc.com?Login&password=pass&username=usr&redirectto=File/myfile.txt
but what has been downloaded to my C:\ is the login page(in myfile.txt)

but when i use the url on the web browser( https://www.abc.com?Login&password=pass&username=usr&redirectto=File/myfile.txt
)
i managed to get the file (the actual file).

Question:
is there anyway that i can download the file from a login page?
do you get what i mean?

Thanks

koh
Junior Poster in Training
73 posts since Jul 2004
Reputation Points: 11
Solved Threads: 0
 

>i want to download a file from a SSL web to my local(C:\)
Think about WebRequest class. Read sknake's post - http://www.daniweb.com/forums/thread203253.html

__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 
>i want to download a file from a SSL web to my local(C:\) Think about WebRequest class. Read sknake's post - http://www.daniweb.com/forums/thread203253.html

Thanks for your reply :D
but im using webrequest class as welll....
but it doesnt seems working....
i compared the code as described and my code..
about the same.
Is there something need to be done on the login session?

anyway, here is my code,
thanks :D

Dim wr As HttpWebRequest
        Dim ws As HttpWebResponse
        Dim str As Stream
        Dim inBuf(1000000) As Byte
        Dim bytesToRead As Integer = CInt(inBuf.Length)
        Dim bytesRead As Integer = 0
        Dim request

        request = WebRequest.Create(sRemoteUrl)
        wr = CType(request, HttpWebRequest)
        ws = CType(wr.GetResponse(), HttpWebResponse)


        str = ws.GetResponseStream()
        While bytesToRead > 0
            Dim n As Integer = str.Read(inBuf, bytesRead, bytesToRead)
            If n = 0 Then
                Exit While
            End If
            bytesRead += n
            bytesToRead -= n
        End While
        Dim fstr As New FileStream(sFile, FileMode.OpenOrCreate, FileAccess.Write)
        fstr.Write(inBuf, 0, bytesRead)
        str.Close()
        fstr.Close()
koh
Junior Poster in Training
73 posts since Jul 2004
Reputation Points: 11
Solved Threads: 0
 

>Is there something need to be done on the login session?

Read MSDN FAQ .

__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

Thanks for your guys' url/article.
The only missing is the cookie session.
Really appreciate your guy's assistance :D

koh
Junior Poster in Training
73 posts since Jul 2004
Reputation Points: 11
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: