Solved

Async File Move in Web App .NET 4.0

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

Industry Leaders: 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

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

718 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