【发布时间】:2010-03-25 20:14:25
【问题描述】:
我正在开发一个网络应用程序,需要流式传输各种文件。我可以处理 pdf、图像和旧版 Office 文档。但是,当我尝试处理 2007 文档时,它会中断。这是我的代码:
Response.Buffer = true;
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
switch (FileExtension.ToLower())
{
case "pdf":
Response.ContentType = "application/pdf";
break;
case "doc":
Response.ContentType = "application/msword";
break;
case "docx":
Response.ContentType = "application/vnd.ms-word.document.12";
break;
case "xls":
Response.ContentType = "application/vnd.ms-excel";
break;
case "xlsx":
Response.ContentType = "application/vnd.ms-excel.12";
break;
default:
Response.ContentType = "image/jpeg";
break;
}
Response.BinaryWrite(buffer);
我得到的错误是:
在文本内容中发现无效字符。错误处理资源'http://DomainName/GetFile.aspx... PK有什么建议吗?
【问题讨论】: