|
Rank: Advanced Member Groups: Member
Joined: 9/3/2014 Posts: 68
|
Hi,
I don't want to show the file download dialog when EO.WebBrowser loads a local ZIP file (url starts with file://). I use the following code but it will hang up my application:
void _webView_BeforeDownload(object sender, BeforeDownloadEventArgs e) { // Don't show dialog to save file when this file is local if (e.Item.Url.StartsWith("file://")) { e.ShowDialog = false; } }
Thanks.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
Your code looks fine. Please try the same code with our TabbedBrowser sample in the latest build. With the sample you can follow these steps:
1. Change line "e.ShowDialog = true" inside WebView_BeforeDownload handler to "e.ShowDialog = false"; 2. Run the sample; 3. Load a page. Click the "=" menu button, then click "Download" from the drop down menu to display the download panel; 4. Download a file;
You will see a new download item is added to the download panel and the download progress growing. Note that the WebView continues to work.
Please let us know if you see anything differently.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 9/3/2014 Posts: 68
|
I get the latest download with EO.WebBrowser build 3.0.95.0, run the TabbedBrowser project with e.ShowDialog = false and see no error. The web browser will download the file directly to Temp folder and display Download pane at the bottom.
However, my project uses the the same latest version 3.0.95.0 from Nuget. It will suddenly stop working after passing through e.ShowDialog = false. It also generates the same error with e.ShowDialog = true. After I choose the folder to save, it also stops the app suddenly.
I guess the issue may be from the Download pane does not know where to locate correctly. I put the EO.WebBrowser.WinForm.WebControl into a user control, and show the DevTools in another control using webView.ShowDevTools(handle) with handle is the handle of an existing panel. I think you should have a method to bind the Download pane to an existing panel.
What I want to do is whenever the web browser navigates to local file, for example file://C:/Temp/Package.zip, it will skip to download as it is just there on the local computer. In other words, the web browser will do nothing when it see the local file (starts with file://) is downloadable.
Thanks.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
You can not cancel the download immediately inside BeforeDownload handler. To cancel the download, you must:
1. Handle BeforeDownload event and set e.ShowDialog to false. This prevent any UI to be displayed; 2. Handle DownloadUpdated event and call e.Cancel() inside the event handler. This cancels the actual download task;
The download Panel in our sample is just the front end UI. It has nothing to do with the back end download tasks.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 9/3/2014 Posts: 68
|
Hi,
e.ShowDialog = false with shut down my app promptly. I added e.Item.Cancel() on webView_DownloadUpdated but this does not help to prevent the app termination.
Do you have any idea about it. My app is really big and I cannot send the whole solution to test.
Thanks.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, We have tested the above approach here and it works fine here. If you believe the problem is related to our product, you can isolate the problem into a test project and send us the test project. Note that you need to isolate the problem into a test project. You can see the test project guideline/instructions here: http://www.essentialobjects.com/forum/test_project.aspxThanks!
|
|