我的应用的用户可以通过单击此文件的链接查看其他用户上传的文件。返回文件响应是这样在MVC中完成的:使用IE轻松打开的文件,并非总是用Firefox打开(“内容已损坏”)
public ActionResult GetFile(int id)
{
Attachment attachment = applicationService.GetAttachment(id);
HttpContext.Response.ClearHeaders();
HttpContext.Response.ContentType = attachment.MimeType;
HttpContext.Response.AppendHeader("Content-Disposition", "attachment; filename=\"" + attachment.FileName + "\"");
return File(attachment.FileContent, attachment.MimeType, attachment.FileName);
}
没什么特别的。它总是在IE中工作,它并不总是在Firefox中工作。即使IE打开它没有问题,一些文件的Firefox说“内容已损坏”。
什么问题?