Solved

Async File Move in Web App .NET 4.0

Posted on 2013-10-22
1
42 Views
Last Modified: 2016-01-06
I have an ASPX 4.0 page (with Async="true") that contains a user control with a Telerik RadGrid. Each row contains a button that causes an AJAX postback when clicked. When the user clicks the button I am trying to copy a PDF file from one server to this one. This works but the page is waiting until the entire file is completed before the postback completes. I am only wanting to "kickoff" the file copy when the user clicks the button then allow them to continue doing other things without having to wait for the large files to complete copying. I would have figured that doing this asynchronously would have worked but the AJAX panel is still waiting for the operation to complete.

Here is the relevant code that gets called when the user clicks the button:

Public Sub GetPDF(ByVal newFileLocationAndName As String, ByVal origFileLocationAndName As String)
                Dim myWebClient As WebClient = New WebClient
                AddHandler myWebClient.DownloadFileCompleted, AddressOf WebClient_DownloadFileCompleted
                myWebClient.DownloadFileAsync(New Uri(newFileLocationAndName), origFileLocationAndName)
End Sub

Private Sub WebClient_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)
                Dim wc As WebClient = DirectCast(sender, WebClient)
                RemoveHandler wc.DownloadFileCompleted, AddressOf WebClient_DownloadFileCompleted
                wc.Dispose()
End Sub
0
Comment
Question by:simonajbart
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 12

Accepted Solution

by:
deanvanrooyen earned 500 total points
ID: 39620162
your code looks ok, have you tried it without the event handler just to check if there isnt any sort of un-handled exception or something weird going on. Looks like download async hits up DNS first.

Also its a bit confusing as your are throwing this all into mix - telerik/ajax panels/ and async code, seems like you are trying to knock in a pin with a 8 pound hammer...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question