[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

download PDF files from website

Asked by Sigh_Man in Microsoft Visual Basic.Net, .NET, .NET Framework 2.x

Tags: WebBrowser, file download

I am trying to automate the download of several PDF documents from a secure website that requires a login.  The website uses https and requires a login (which of course I have).

When I try to make WebRequest GetResponse calls it fails with a 401 error - Requires Authentication - even though I can navigate to the PDF form using the WebBrowser1.Navigate("[URLOfPdfFileHere]") method.  "Stuff" must be happening at the server side, which means there is no direct URL address for each of the PDF documents - so, typically, when clicking manually on a document link the URL would be shown in the status bar of the browser as:
https://www.theirsite.com/subscription/cheatsheets/NXT/gateway.dll?f=id$id=cheatsheets_form_1_pdf$t=document-frame.htm$3.0$p=

I have tried the following to get this working:
Dim oDownload As New System.Net.WebClient
URLReq.Credentials = New NetworkCredential("MYUSERNAME", "MYPASSWORD", wb1.Document.Domain.ToString)
oDownload.DownloadFile(https://www.theirsite.com/subscription/cheatsheets/NXT/gateway.dll?f=id$id=cheatsheets_form_1_pdf$t=document-frame.htm$3.0$p=", "C:\test\cheatsheet1.pdf")  ' ------FAILS HERE WITH A "401 ERROR - REQUIRES AUTHENTICATION"

When setting the Credentials, I used the "wb1.Document.Domain.ToString" value because I figured that whatever network credential WebBrowser1 was using must be OK - since I was able to navigate to the forms with WebBrowser1.  I have also used:
oDownload.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials
...but this too did not work.  Same "401" error.

One idea I tried was to actually one by one navigate to the link for each document and then when the browser loads the form (within an Adobe Reader frame) programmatically do a "Save As" to save the form to disk.  EXCEPT - I then cannot get a handle on the Adobe Reader frame within that webbrowser control to do the Save As.  If I execute the following:
WebBrowser1.Navigate("https://www.theirsite.com/subscription/cheatsheets/NXT/gateway.dll?f=id$id=cheatsheets_form_1_pdf$t=document-frame.htm$3.0$p=")
...then the PDF file opens up within WebBrowser1 - but then I cannot figure out how to get the file out of the WebBrowser (manually, I would simply hit the save button in the WebBrowser's Adobe Reader toolbar, but I am trying to automate this to not require user input).
[+][-]11/11/09 03:20 AM, ID: 25794057Accepted Solution

Your question has an Asker Certified™ answer! Sigh_Man verified that this solution worked for them--which means it will likely work for you, too. Click to view the solution free for 30-days now.

About this solution

Zones: Microsoft Visual Basic.Net, .NET, .NET Framework 2.x
Tags: WebBrowser, file download
Sign Up Now!
Solution Provided By: CodeCruiser
Participating Experts: 2
Solution Grade: A
 
[+][-]11/11/09 12:27 AM, ID: 25793153Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/11/09 02:52 AM, ID: 25793887Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/11/09 03:51 AM, ID: 25794242Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20100308-EE-VQP-141 - Hierarchy / EE_QW_3_20080625
Your technology problems solved.
Close See Plans and Pricing. Try it FREE for 30 days.