OnSuccess event does not work on KendoUI Upload component

2 posts, 0 answers
  1. Igor Stanek
    Igor Stanek avatar
    18 posts
    Member since:
    Jan 2008

    Posted 20 May 2015 Link to this post


    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?


  2. Dimiter Madjarov
    Dimiter Madjarov avatar
    2312 posts

    Posted 21 May 2015 Link to this post

    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.

    Dimiter Madjarov
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top