1

I have used Kendo Upload functionality to upload the files. And used asynchronous upload.

$('#File').kendoUpload({
async: {
         saveUrl: '@Url.Action("FileUpload", "Upload")',
         autoUpload: false,
       },
success: function (data) {  },

error:
                 function (data) {}
});

And in my controller, i am returning the success or error message in the below way:

return Json(GetModelStateErrors, JsonRequestBehavior.AllowGet); //for error
return Content("success");

But, after upload even if controller returns error, it will hit the success event in Kendo Upload. And if the file uploaded successfully to the database, it hits to error event in Kendo Upload.

please help me to resolve this issue. Let me know if u need more clarification.

Thanks in Advance,

tereško
  • 58,060
  • 25
  • 98
  • 150
Lak
  • 146
  • 2
  • 15
  • The error function is only hit when there is an error (for example an exception is thrown on the server), not just because you return a message. –  Sep 12 '14 at 11:46

1 Answers1

2

In order to hit the success you must return a blank string, in Kendo this signifies a success i.e.

// Return an empty string to signify success
return Content("");

For further info please see here:

http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/upload/metadata

hutchonoid
  • 32,982
  • 15
  • 99
  • 104
  • Thanks for the reply. Yes it works if i send empty string in controller onsucces. But it hits success event when i send Json(GetModelStateErrors); I want to display the error. What can be the solution for this? – Lak Sep 12 '14 at 12:36
  • Yes...success got resolved. But success event fires even if i have validation error. Means, if i send validation message through Json(GetModelStateErrors) i want that to fire to error event rather than success. So , how this can be resolved? – Lak Sep 12 '14 at 13:14
  • @Nam That is a different question as to the original one asked. Pls create another, you will get more chance of it getting answered. I would have to investigate that further, not sure of hand. – hutchonoid Sep 12 '14 at 13:27
  • @Nam No probs, will see if I can get it for you. :) – hutchonoid Sep 12 '14 at 13:47