【发布时间】:2013-06-06 23:01:06
【问题描述】:
我想允许客户端下载附件。这里attachment.AttachmentContent 是文件中的字节数组。当我单击按钮下载附件时,它会在下面运行此代码。但我有以下脚本错误。我应该怎么做才能修复它?
未捕获的 Sys.WebForms.PageRequestManagerParserErrorException: Sys.WebForms.PageRequestManagerParserErrorException:消息 从服务器收到的无法解析。造成这种情况的常见原因 错误是通过调用 Response.Write() 修改响应时, 响应过滤器、HttpModules 或服务器跟踪已启用。细节: '����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();
【问题讨论】: