Setting ContentType = "image/tiff" and sending an image is not working in IE
<p>I need to send an image (as a downloadable file) from an ASP web page.  It is working correctly in every browser except for IE (all versions).</p>

<p>Here is the server side code:</p>

<pre><code>bool export = Request.QueryString["Export"] != null;
if (export)
{
    byte[] allBytes = File.ReadAllBytes(@"C:\MyImage.tif");
    Response.ContentType = "image/tiff";
    Response.AddHeader("content-disposition", "attachment; filename=\"MyImage.tif\"");
    Response.OutputStream.Write(allBytes, 0, allBytes.Length);
    Response.OutputStream.Flush();
    Response.End();
    return;
}
</code></pre>

<p>And here is the JavaScript:</p>

<pre><code>$('#ExportFrame').attr('src', 'Default.aspx?Export=true'); // ExportFrame is an iframe
</code></pre>

<p>In IE, I keep getting an error saying "Internet Explorer cannot download Default.aspx from localhost".  I thought it might be an issue with loading it in an iframe element, but redirecting to the URL is not working either.  The really odd thing is that going to the URL (/Default.aspx?Export=true) does not work the first time, but works every time after that.  Again, this works in every browser I've tried except IE.</p>

<p>Any ideas?</p>

<p>Update:
The aspx page has the following code to keep the page from getting cached:</p>

<pre><code>// Never cache this page
Response.CacheControl = "no-cache";
Response.AddHeader("Pragma", "no-cache");
Response.Expires = -1;
</code></pre>

<p>Removing the first 2 lines and leaving only <code>Response.Expires = -1</code> resolved the issue.</p>
