我有一個用戶報告說文件在瀏覽器中顯示爲原始數據。他使用Internet Explorer。PDF文件有時顯示爲垃圾
這些文件通過.ashx處理程序文件進行處理,它一直在工作。
這是我的ashx的處理程序的相關部分:
context.Response.Clear()
context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + name)
context.Response.AppendHeader("Content-Length", size.ToString)
context.Response.ContentType = "application/pdf"
context.Response.TransmitFile(fullname)
context.Response.Flush()
HttpContext.Current.ApplicationInstance.CompleteRequest()
更新:當運行IE 11或Edge並且僅在第二次打開文件時,此行爲出現在Windows 10上。它發生在.pdf和.docx文件中。