Member Avatar for kohkohkoh

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

Member Avatar for kohkohkoh

>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()

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

Read MSDN FAQ.

Member Avatar for kohkohkoh

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.