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

OnSuccess event does not work on KendoUI Upload component

1 Answer 452 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Igor Stanek
Top achievements
Rank 1
Igor Stanek asked on 20 May 2015, 02:17 PM
Hello!

We have problem with "Upload" component.

It's looks like event "OnSuccess" on it (on Upload component) does not work.

We use asynchronous upload, and  Upload component is routed to web api controller method in which we process upload.

When everything went ok with upload we set response status code [OK] (200) and we also trying to sent some data as Content back to client.

Our server-side code (in method in ASP.NET Web API controller in which we process upload from Upload component) looks like:

HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
response.Content = new StringContent("File was succesfuly uploaded");    
response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/plain");
return response;

When we try do things this way, then Upload component on client-side activates OnError event instead of OnSuccess event. 

Why is that? And is there some workaround for this?


thanks,
Igor.

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 21 May 2015, 11:33 AM

Hello Igor Stanek,

The reason for this behavior is that Upload widget requires the response to be in JSON format with Content-Type set to "text/plain". Any non-empty response that is not JSON will be treated as a server error.

I hope this information helps.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Upload
Asked by
Igor Stanek
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or