dimanche 26 octobre 2014

How to cancel an upload


Vote count:

0




I have a asp.net web api page where the user can upload some files. I am using jquery-file-upload. Based on some condition, I want to cancel the upload from the server side but it is not working. No matter what I do, the file always goes to the server before asp.net returns the error. Example, I can keep just this when uploading:



public async Task<HttpResponseMessage> Post(int id, CancellationToken token)
{
return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Cant upload");
}


If I put a breakpoint on the return, I can see that it it hitted as soon as the upload starts but I have to wait the upload to end and only then the javascript error handler gets called. Is it not possible to end the request imediatelly, cancelling the upload?



asked 44 secs ago

Leo

2,722






How to cancel an upload

Aucun commentaire:

Enregistrer un commentaire