Long time of execution of FileUploaded event leads to exception

  •  12-03-2012, 8:45 AM

    Long time of execution of FileUploaded event leads to exception

    Hi

    I have a big and slow code for event FileUploaded.

    During execution of this code, i've got an exception message:

    Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object.

    In js code function

    function Sys$WebForms$PageRequestManager$_endPostBack

     

    Also, if i try debug the event FileUploaded very slowly, i've got this message too.

     

    1. protected void fileinput_FileUploaded(object sender, UploaderEventArgs args) 
    2.         { 
    3.             Uploader uploader = (Uploader)sender; 
    4.             Uploader uploaderControl = null
    5.  
    6.  
    7.             foreach (Control c in this.UpdatePanel1.ContentTemplateContainer.Controls) 
    8.             { 
    9.                 if (c is Uploader) 
    10.                 { 
    11.                     if (c.Visible) 
    12.                     { 
    13.                         uploaderControl = (Uploader)c; 
    14.  
    15.  
    16.                         if (uploaderControl.ID == uploader.ID) 
    17.                         { 
    18.                             string path = "C:\\UploaderTempNew\\"
    19.                             args.MoveTo(path + args.FileName); 
    20.                         } 
    21.                     } 
    22.                 } 
    23.             } 
    24.       } 
     

    After i've got an exception, the uploader stops working and page not refreshed.

    As result - the .resx files not deleted after uploading.
     
    How i can execute big and slowly code  without this exception?

View Complete Thread