Reputation: 749
From Service method return me:
String FileName,
Byte[] FileData,
string FileType( includes: doc, pdf, tif, tiff, gif, jpg, jpeg, png, bmp, wpd)
How can I generate a file based on filetype and show it to user in browser? Download to user is ok for me.
Upvotes: 0
Views: 3412
Reputation: 1039458
// You will need to figure out the correct content type based on the file type
// for example image/jpeg for jpeg files
Response.ContentType = ...;
var cd = new ContentDisposition()
{
Inline = true,
FileName = FileName
};
Response.AppendHeader("Content-Disposition", cd.ToString());
Response.OutputStream.Write(FileData, 0, FileData.Length);
Upvotes: 2