I want to allow client to download attachment. Here attachment.AttachmentContent
is bytes array from file. When I click on the button to download attachment it runs this code below. But I have the following script error. What should I do to fix it ?
Uncaught Sys.WebForms.PageRequestManagerParserErrorException: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. Details: Error parsing near '����JFIF``'.
Attachment attachment = _attachmentService.GetAttachmentBytesById(int.Parse(e.CommandArgument.ToString()));
Response.Clear();
Response.ClearHeaders();
Response.ContentType = "image/jpeg";
Response.AddHeader("Content-Disposition", "attachment; filename=\"" + "test.jpg" + "\"");
Response.OutputStream.Write(attachment.AttachmentContent, 0, attachment.AttachmentContent.Length);
Response.End();