I have a scenario where I want to prevent users from uploading a file if another file with the same name has been uploaded elsewhere. I create the upload like this
this
.$(
"#templateFile_"
+ id).kendoUpload({
async: {
saveUrl:
"/KendoUploadFileHandler.ashx?upload=1"
,
removeUrl:
"/KendoUploadFileHandler.ashx?remove=1"
,
autoUpload:
true
},
showFileList:
false
,
multiple:
false
,
upload:
this
.onUpload,
success:
this
.onSuccess,
progress:
this
.onProgress,
select:
this
.onSelect,
error:
this
.onError
});
The upload handler is a custom httphandler where I inspect
HttpPostedFile postedFile = context.Request.Files["templateFile"];
to see if postedFile.FileName already exists on disk. If so, I'd like to return an error to the client and carry this information along.
If I set context.Response.StatusCode to e.g. 500 (InternalServerError) I hit my error handler (onError) - but the error get caught in kendo.web.min.js as well and I get the entire server response dumped to console from kendo.web.min.js. This also happens if I set StatusCode to "OK" but provide a value in context.Response.Status.
If I just return a statuscode OK with a statusdescription, I never hit my error handler.
There is very little documentation about this, I am out of idead for further trial-and-error tests. Could you please provide a simple working example (or some sample code) where some validation in the httphandler HandleRequest(HttpContext context) will cause the clientside code to end in either onSuccess or onError.
Thanks for any help!
/Jan