I am using web api http get call which returns the response as below in controller. 'pck' below is of type ExcelPackage.
{
Byte[] fileBytes = pck.GetAsByteArray();
var response = new HttpResponseMessage(System.Net.HttpStatusCode.OK);
var fileStream = new MemoryStream(fileBytes);
response.Content = new StreamContent(fileStream);
response.Content = new ByteArrayContent(fileBytes);
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
response.Content.Headers.ContentDisposition.FileName = DataTable.TableName + '_' + dt + ".xlsx";
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/ms-excel");
response.Content.Headers.ContentLength = fileStream.Length;
response.StatusCode = System.Net.HttpStatusCode.OK;
return response;
}
Now, in angularjs I want to download this response as excel file. How can I do the same?
I don't want to use any other jquery. So, and also dont want to use window.location.href. As, I am authorizing this method, I want to stick to http get call only.