This is a migrated thread and some comments may be shown as answers.

Return the error from CustomHttpHandler

2 Answers 13 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Rakesh
Top achievements
Rank 1
Rakesh asked on 18 Jul 2014, 12:22 AM
Hi
I am using Radasyncupload and using a customhttphandler and saving files directly to the database. Sometimes the handler is failing because of some error in the code like DB is not available or someother error  and I want to return the exact error message to the application. How can I accomplish this? Any help is much appreciated.

Thanks
Rakesh

2 Answers, 1 is accepted

Sort by
0
Accepted
Hristo Valyavicharski
Telerik team
answered on 22 Jul 2014, 11:25 AM
Hi Rakesh,

Handle the error in the Handler and return custom result.
protected override IAsyncUploadResult Process(UploadedFile file, HttpContext context, IAsyncUploadConfiguration configuration, string tempFileName)
 {
     // Call the base Process method to save the file to the temporary folder
     // base.Process(file, context, configuration, tempFileName);
 
     // Populate the default (base) result into an object of type SampleAsyncUploadResult
     SampleAsyncUploadResult result = CreateDefaultUploadResult<SampleAsyncUploadResult>(file);
 
     int userID = -1;
     // You can obtain any custom information passed from the page via casting the configuration parameter to your custom class
     SampleAsyncUploadConfiguration sampleConfiguration = configuration as SampleAsyncUploadConfiguration;
     if (sampleConfiguration != null)
     {
         userID = sampleConfiguration.UserID;
     }
       
     // Populate any additional fields into the upload result.
     // The upload result is available both on the client and on the server
     result.ImageID = InsertImage(file, userID);
       
     return result;
 }

Similar to this online demo:
http://demos.telerik.com/aspnet-ajax/asyncupload/examples/imageuploader/defaultcs.aspx

I hope this helps.

Regards,
Hristo Valyavicharski
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Rakesh
Top achievements
Rank 1
answered on 20 Aug 2014, 01:59 PM
Thank you. It worked
Tags
AsyncUpload
Asked by
Rakesh
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
Rakesh
Top achievements
Rank 1
Share this question
or