Hi there,
I'm using WebApi ApiController endpoint to get a document.
I can't use .SaveToFile, since it expects HttpResponse rather than HttpResponseMessage available on ApiController.
I'm trying to use this approach, but it doesn't work either:
//Save doc file.
var stream = new MemoryStream();
// processing the stream.
document.SaveToStream(stream, FileFormat.Docx);
var result = new HttpResponseMessage(System.Net.HttpStatusCode.OK)
{
Content = new ByteArrayContent(stream.GetBuffer())
};
result.Content.Headers.ContentDisposition =
new ContentDispositionHeaderValue("attachment")
{
FileName = "CSample.docx"
};
result.Content.Headers.ContentType =
new MediaTypeHeaderValue("application/octet-stream");
return result;
Thanks in advance