Suppressing download dialog with Awesomium.NET

Recently I wanted to automatically trigger and extract some backup files from a web application. Their smug support guy told me this wasn't possible, so I started to throw together a little scraper to prove them wrong.

This particular web app does some funky stuff with javascript when authenticating users, so I couldn't use the HttpWebRequest or WebClient classes. Given that the built-in Web Browser control is a pile of shit, I installed the Awesomium SDK which turned out to be very pleasant to work with. You can just inject your own JS which gives you a lot of flexibility.

I ran across an issue when triggering the actual download of my backup file. A download file dialog displays by default, which is less than ideal. The documentation doesn't do a great job of explaining how to override this behavior, so here's a quick overview of what I did in VB.NET:

Pop this in with your import statements:

Imports Awesomium.Core

Add an event handler:

AddHandler WebCore.Download, AddressOf SkipDLPath

And then put something like this in your handler method:

Private Sub SkipDLPath(sender As Object, e As DownloadEventArgs)
Dim DLPath as String = "C:\Backups\myBackup.zip"
e.Handled = True
e.SelectedFile = DLPath
End Sub

The file chooser prompt should be suppressed and Awesomium will happily start downloading the file. I monitored the progress and completion using the DownloadItem class.

Voilà!
scraper

1 Comment Suppressing download dialog with Awesomium.NET

  1. Tim

    I couldn't figure out exactly how to do this with awesomium. Setting the e.SelectedFile property is what I was missing. Thanks!!!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *