Solved

Async File Move in Web App .NET 4.0

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
https://github.com/willowsystems/jSignature 11 73
Create animated movies for web page 18 84
SSRS Deployment problem 5 64
using CK editor in iframes 5 16
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 article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

856 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