Link to home
Start Free TrialLog in
Avatar of HLRosenberger
HLRosenbergerFlag for United States of America

asked on

Using SHDocVw.InternetExplorer and WebClient.DownloadFile

I'm using SHDocVw.InternetExplorer.  I have a screen scraper app.  The site I am scraping requires a username/password to login.    Once logged in, there is a file I want to download. WebClient.DownloadFile works great for a site/page that does not require authentication.  When I try to download my file from this secure site, I get this:   <script>alert('Please login first before continuing'); window.location.href = '/XXXConnect/public/Login';</script>.

Can I pass along the authentication credentials from SHDocVw.InternetExplorer to WebClient?
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

You will have to programmatically login to the site, get the authentication cookie and then send that cookie with a httpwebrequest object to download the file

http://m4sh3d.blogspot.co.uk/2011/05/login-to-website-and-download-file.html

http://stackoverflow.com/questions/4699938/how-to-download-the-file-using-httpwebrequest-and-httpwebresponse-classcookies
Avatar of HLRosenberger

ASKER

You have pointed me to something similiar in the past.  I create the code from the first code exactly.   This does not work.   The WEB site that I'm trying to download the file from has a login page.      I do not see how passing the username/password  (see below) as post data accomplishes the same thing as logging in via a WEB page where a username and password is entered.  In the downloadFile function, I still get the same error message as I specified in my original post.

Dim postData As String = "user_name=" & uid & "&user_password=" & pwd
ASKER CERTIFIED SOLUTION
Avatar of HLRosenberger
HLRosenberger
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The code I found at the link I provided works.