Question download dynamically generated file from indirect url

AayZee

New member
Joined
Aug 28, 2013
Messages
2
Programming Experience
1-3
Sorry if its not the correct category to post in.

I am trying to download a dynamically generated report.csv from a website link which requires login to get it downloaded.

I tried by logging in through WebBrowser Control and navigating it to report's link but it shows "File Download" dialog as I want it to download silently knowing the downloaded location. Not sure if there is a proper to do it beside WebClient DownloadFile method because for some reason I didn't find any luck transferring sessions/cookies using following code and instead of that report it downloads login page.

VB.NET:
myWebClient.Headers.Add(HttpRequestHeader.Cookie, WebBrowser1.Document.Cookie)

Have also tried HttpWebRequest and it also downloads login.asp

Any idea how I can get this issue resolved?

Thanks in Advance
 
Unfortunately you cannot do that with a dynamically generated file PUSHed by the server through an ASP script, as there is no URL to download the file. The URL points to the ASP script which generates the file and initiates the transaction. Normally the client initiates the transaction to PULL the file from the server, as does the DownloadFile method. If you try to DownloadFile on the ASP URL, you will get the ASP file itself. You should however be able to handle the download dialog through UI automation (Win32 FindWindowEx & EnumWindow, MSAA, or UIA). With that said, why not let the user decide where he wants to save the CSV file?
 
Last edited:
Unfortunately you cannot do that with a dynamically generated file PUSHed by the server through an ASP script, as there is no URL to download the file. The URL points to the ASP script which generates the file and initiates the transaction. Normally the client initiates the transaction to PULL the file from the server, as does the DownloadFile method. If you try to DownloadFile on the ASP URL, you will get the ASP file itself. You should however be able to handle the download dialog through UI automation (Win32 FindWindowEx & EnumWindow, MSAA, or UIA). With that said, why not let the user decide where he wants to save the CSV file?

You are the man!! Now it totally makes sense :) Actually I can not let the user decide because I am writing a cron app and I have to email this report with some editing.

Do you suggest timer approach to detect Download File dialog or it can be traced on some other webbrowser event?


Thank you so much!!!!!!
 

Latest posts

Back
Top