Steven
Steven

Reputation: 180

Download PDF in ASP Error on Some Machines

I am using this code to generate pdf's to download on an ASP page and the pdf does download properly on some pages but not on all. Several users are experiencing an error message as seen in the attached image. Please let me know if you have suggestions on how to fix this problem. It is sporadic so its been hard to nail down a cause.

Public Sub Download(filename As String)
    Response.Clear()
    Response.BufferOutput = False
    Response.ContentType = "application/pdf"
    Response.AddHeader("content-disposition", "attachment; filename=" + Path.GetFileName(filename))
    Response.WriteFile(filename)
    Response.Close()

End Sub

error

Upvotes: 2

Views: 67

Answers (1)

Daniel Manta
Daniel Manta

Reputation: 6683

Try Response.Flush(), followed by Response.End().

Upvotes: 1

Related Questions