err_response_headers_multiple_content_disposition

err response headers multiple content disposition in chrome

When we tried to view a pdf file from a website link then the browser shows err_response_headers_multiple_content_disposition error. It’s not the browser’s issue. It is actually an issue with response header content.

err_response_headers_multiple_content_disposition error page
err_response_headers_multiple_content_disposition error page

Peoples are complaining that this problem is occurring in their chrome browser. We think it’s not actually the Chrome browser issue. Let’s explain why it is actually happening.

Why “err response headers multiple content disposition” error occurs?

Most commonly we can serve PDF files from our web server in two ways. We can give direct URL pointed into our web server’s public location. Another way is writing PDF content at the response.

When we write PDF content into response then we provide some header like content-type and file name. This way, it will work for most of the pdf file. But problem will occur when a comma contains in file name which we set at header as filename.

How to solve this problem?

For solving this problem we have to remove or replace comma from pdf filename before setting into header.

ASP.NET Fix Example Code

ASP.NET MVC 5 has built in support for returning file response. We only need to remove special characters from the file name.

Use following way for downloading a PDF file.

public FileResult DownloadPdf()
{
  var filePath = Server.MapPath("~/Download Visual Studio 2017 ISO,Offline Installer.pdf");
  var fileInfo = new FileInfo(filePath);
  var pdfFile = System.IO.File.ReadAllBytes(filePath);

  var fileName = fileInfo.Name;

  //Only this line is required for solving the issue
  var safeFileName = fileName.Replace(",", "_");

  return File(pdfFile, "application/pdf", safeFileName);
}

PHP Fix Example Code

PHP also allow to add customer header at the response. For PHP script use following code for fixing the pdf downgliding issue.

$pdfFileName = str_replace(",", "_", "your_pdf_file,Name.pdf");
header('Content-Disposition:attachment; filename=file,'.$pdfFileName);

Conclusion

Special character in HTTP headers causes this issue. Hope this article will help you for resolving the issue. Thank you for reading the article. If you have any other questions please ask questions at LearnersHeaven Question/Answer section. Our experts and community users will answer your questions.