Thanks for raising this. Downloads were not previously exposed by HTMLViewer, which is why clicking those links appeared to do nothing.
I’ve now implemented native download support for the next Objo Studio release on Windows, macOS, and Linux:
https://feedback.objo.dev/feature/898
Crucially, the download is performed by the same native browser session used by HTMLViewer. That means its authentication cookies, redirects, and logged-in session are preserved. There’s no need to reproduce the request with curl.
The default policy is Ask, which displays the platform’s normal save dialog. Existing projects therefore won’t require any code:
HTMLViewer1.DownloadPolicy = HTMLViewerDownloadPolicy.Ask
Other options are:
# Save automatically using a unique filename.
HTMLViewer1.DownloadPolicy = HTMLViewerDownloadPolicy.DownloadsFolder
# Prevent all downloads.
HTMLViewer1.DownloadPolicy = HTMLViewerDownloadPolicy.Block
For more control, three new events are available:
DownloadRequested(download As HTMLViewerDownload) As Boolean
DownloadProgressed(download As HTMLViewerDownload)
DownloadFinished(download As HTMLViewerDownload)
For example:
Function HTMLViewer1_DownloadRequested(download As HTMLViewerDownload) As Boolean
# Return True to reject this download.
Return False
End Function
Sub HTMLViewer1_DownloadFinished(download As HTMLViewerDownload)
Select Case download.State
Case HTMLViewerDownloadState.Completed
MessageBox("Saved to " + download.Destination.Path)
Case HTMLViewerDownloadState.Failed
MessageBox("Download failed: " + download.ErrorMessage)
End Select
End Sub
HTMLViewerDownload exposes the URL, suggested filename, content type, byte counts, destination, state, and any error details. It also provides SaveTo() for choosing a destination in code and Cancel() for stopping a download.
Downloads are written to uniquely named temporary files and moved to their final destinations only after successful completion. Cancellation, cleanup, filename collisions, progress reporting, and concurrent-download limits are handled by Objo.
The implementation uses the public native platform handles supplied by Avalonia and the operating system’s browser APIs—WebView2 on Windows, WKWebView on macOS, and WebKitGTK/WPE on Linux. It does not patch or fork Avalonia.
An example will be bundled with Studio in the next release as well.