i'm writing some code to download a jpeg. the jpeg is passed in the url
there is nothing in the aspx file except
here is the important bit
it works perfectly on firefox. but on internet explorer, the save file dialog box says that the file is 'images_jpg', and the type is 'HTML Document'. then, when i click save, i get told 'ie wasn't able to open this site. the site can't be found' (paraphrased).
the response header says
which looks right to me.
what do i need to do? does any body have either some working code for this, or an idea of what i need to change? ta
Code:
PictureLoader.aspx?picture=images/image.jpg
there is nothing in the aspx file except
Code:
<%@ Page language="c#" Codebehind="PictureLoader.aspx.cs" AutoEventWireup="false" Inherits="MySolution.PictureLoader" %>
here is the important bit
Code:
private void Page_Load(object sender, System.EventArgs e)
{
Response.Cache.SetExpires(DateTime.Now);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetValidUntilExpires(false);
if(!IsPostBack)
{
downloadPic(Request.Params["picture"]);
}
}
private void downloadPic(string strFileName)
{
FileStream fsStream;
long iFileSize;
fsStream = new FileStream(Server.MapPath(strFileName), FileMode.Open);
iFileSize = fsStream.Length;
byte[] Buffer = new byte[iFileSize];
fsStream.Read(Buffer, 0, (int)iFileSize);
fsStream.Close();
Response.AddHeader("Content-Disposition", "attachment; filename=" + strFileName);
Response.AddHeader("Content-Length", iFileSize.ToString());
Response.Charset = "UTF-8";
Response.ContentType = "image/jpeg";
Response.BinaryWrite(Buffer);
Response.Flush();
}
it works perfectly on firefox. but on internet explorer, the save file dialog box says that the file is 'images_jpg', and the type is 'HTML Document'. then, when i click save, i get told 'ie wasn't able to open this site. the site can't be found' (paraphrased).
the response header says
Code:
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Fri, 16 Sep 2005 11:34:31 GMT
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Content-Disposition: attachment; filename=ranges/jakarta.jpg
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Content-Type: image/jpeg; charset=UTF-8
Content-Length: 44402
what do i need to do? does any body have either some working code for this, or an idea of what i need to change? ta