Tôi có một phần trên trang web nơi tôi hiển thị pdf bên trong hộp đèn. Việc nâng cấp chrome gần đây đã phá vỡ này hiển thị:Chrome, hiển thị pdf, Tiêu đề trùng lặp nhận được từ máy chủ
Lỗi 349 (net :: ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION): Nhiều header Content-Disposition nhận. Điều này không được phép bảo vệ chống lại các cuộc tấn công phân tách phản hồi HTTP.
Điều này vẫn hoạt động chính xác trong IE.
Tôi đang sử dụng ASP.NET MVC3 trên IIS6
Mã tôi sử dụng để tạo tệp như sau.
Nếu tôi xóa câu lệnh nội tuyến, sau đó tải tệp xuống, tuy nhiên sẽ phá vỡ chức năng hộp đèn.
Vấn đề Mã
public FileResult PrintServices()
{
//... unrelated code removed
MemoryStream memoryStream = new MemoryStream();
pdfRenderer.PdfDocument.Save(memoryStream);
string filename = "ServicesSummary.pdf";
Response.AppendHeader("Content-Disposition", "inline;");
return File(memoryStream.ToArray(), "application/pdf", filename);
}
Cách khắc phục
Di
Response.AppendHeader("Content-Disposition", "inline;");
Sau đó Thay đổi
return File(memoryStream.ToArray(), "application/pdf", filename);
để
return File(memoryStream.ToArray(), "application/pdf");
Related: http://stackoverflow.com/questions/1187261/whats-the-difference-between-the-four-file-resu lts-in-asp-net-mvc –
Bản sao có thể có của [Trả lại tệp để Xem/Tải xuống trong ASP.NET MVC] (http://stackoverflow.com/questions/5826649/returning-a-file-to-view- download-in-asp-net-mvc) –
Liên quan: http://stackoverflow.com/a/16673120/109941 –