Note that there are some explanatory texts on larger screens.

plurals
  1. POAsp.Net Sending PDF to browser
    text
    copied!<p>I've been trying to get this aspx page to serve up a pdf. It works correctly in Firefox, but IE gives </p> <blockquote> <p>Internet Explorer cannot download getform.aspx from SERVER_NAME<br> Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found.</p> </blockquote> <p>This is the general functionality of my code. It's spread across multiple functions (this is why we're not using WriteFile - sometimes we generate the pdf on the fly), but this is generally it:</p> <pre><code>FileStream fs = File.Open(Path.Combine(PdfBasePath, "form.pdf"), FileMode.Open, FileAccess.Read); Stream output = Response.OutputStream; byte[] buffer = new byte[BUFFER_SIZE]; int read_count = fs.Read(buffer, 0, BUFFER_SIZE); while (read_count &gt; 0) { output.Write(buffer, 0, read_count); read_count = fs.Read(buffer, 0, BUFFER_SIZE); } fs.Close(); Response.Clear(); Response.ContentType = System.Net.Mime.MediaTypeNames.Application.Pdf; Response.AddHeader("Content-Disposition", "attachment; filename=form.pdf"); Response.Output.Flush(); Response.End(); </code></pre> <p>Looking at Fiddler, the page is being fetched using this:</p> <blockquote> <p>GET /getform.aspx?Failure=Y&amp;r=someencryptedstring HTTP/1.1</p> </blockquote> <p>It is being returned to the browser thus:</p> <blockquote> <p>HTTP/1.1 200 OK<br> Date: Thu, 09 Apr 2009 22:08:33 GMT<br> Server: Microsoft-IIS/6.0<br> X-Powered-By: ASP.NET<br> X-AspNet-Version: 2.0.50727<br> Pragma: no-cache<br> Content-Disposition: attachment; filename=form.pdf<br> Cache-Control: no-cache, no-store<br> Pragma: no-cache<br> Expires: -1<br> Content-Type: application/pdf<br> Content-Length: 628548</p> </blockquote> <p>This is really bugging me. I'm not using SSL, otherwise <a href="http://support.microsoft.com/default.aspx?scid=KB;EN-US;q316431&amp;" rel="nofollow noreferrer">this KB article</a> would seem to apply. Anyone have any ideas?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload