Search code examples
google-chromeresponse.writewritefile

Response Writefile isn't creating a PDF when using Chrome


I'm using the following code to send a PDF to users to open/download. This works fine in IE9. Any ideas why it won't work in Chrome?

Response.Clear();

Response.AddHeader("Content-Disposition", "attachment; filename= \"" + myFile + "\"");
Response.AddHeader("Content-Length", myFile.Length.ToString());

Response.WriteFile(myFile.FullName);

Response.Flush();
Response.End();

Solution

  • Add this:

    Response.ContentType = "application/pdf";