Solved

Async File Move in Web App .NET 4.0

Posted on 2013-10-22
1
37 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
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now