jeudi 5 novembre 2015

$.fileDownload completion action missing

I'm using jquery.fileDownload plugin, and everything works fine, apart of the fact that .done function never gets triggered. File gets downloaded, and nothing happens after

This is my code:

$.fileDownload(self.resourceUrl + '/Export?' + querystring)
.done(function () {
alert('File download a success!');
})
.fail(function () {
alert('File download failed!');
});

This is my controller method (ASP.NET Web API)

public HttpResponseMessage GetExport([FromUri]MyObject myobject)
{
HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
response.Content = new StreamContent(new MemoryStream(...);
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/excel");
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
    FileName = myobject.Title + ".xls"
};
return response;
}

Is it because I'm using API nothing happens after file being downloaded?

Aucun commentaire:

Enregistrer un commentaire