Content-Disposition attachment not working in IE 7
-
Hi, everyone. The situation is, I am converting a tiff image file into byte[], then to stream then saving it as jpeg image format, then display it on browser, so that the jpeg opens in a picture viewer instead of webpage. The code works in IE 6 and firefox, but does not work in IE 7. In IE 7, the blank page appears and automatically closes. The code is as follows:- System.IO.Stream _stream = new MemoryStream(byteArray); Bitmap _bmp = new Bitmap(_stream); Response.Clear(); Response.AddHeader("Content-Disposition","attachment;filename=adc.gif"); Response.ContentType = "image/gif"; _bmp.Save(Response.OutputStream, ImageFormat.Gif); Response.End(); _bmp.Dispose(); _stream.Close(); This code is called in the page_load of a page in server a. Since the tiff image is located on a different server(server b) other than the web server, the image path is passed to web service located at server b, image is read and converted to byteArray and returned to server a. I guess the problem is with Content-Disposition. Any help is appreciated.
-
Hi, everyone. The situation is, I am converting a tiff image file into byte[], then to stream then saving it as jpeg image format, then display it on browser, so that the jpeg opens in a picture viewer instead of webpage. The code works in IE 6 and firefox, but does not work in IE 7. In IE 7, the blank page appears and automatically closes. The code is as follows:- System.IO.Stream _stream = new MemoryStream(byteArray); Bitmap _bmp = new Bitmap(_stream); Response.Clear(); Response.AddHeader("Content-Disposition","attachment;filename=adc.gif"); Response.ContentType = "image/gif"; _bmp.Save(Response.OutputStream, ImageFormat.Gif); Response.End(); _bmp.Dispose(); _stream.Close(); This code is called in the page_load of a page in server a. Since the tiff image is located on a different server(server b) other than the web server, the image path is passed to web service located at server b, image is read and converted to byteArray and returned to server a. I guess the problem is with Content-Disposition. Any help is appreciated.
Try this ============ byte[] message; // converting a tiff image file into byte[] bool ret = false; string filepath = "C:\"; if (Contentdisposition != null) { ret = Contentdisposition.StartsWith(" attachment;"); //code to decode the data if (ret && (contentTransferEncoding.ToUpper().Equals("BASE64"))) { //create the file and store the binart data //store to test create the file with attachment name later string[] filename = Contentdisposition.Split(';'); attachfile = filename[1]; attachfile = Regex.Replace(attachfile, "^[ | ]+filename=[\"]*([^\"]*).*$", "$1"); filepath+=attachfile; m_binaryData = Convert.FromBase64String(message.Replace("\n", "")); System.IO.BinaryWriter bw = new BinaryWriter(new FileStream(filepath, System.IO.FileMode.Create)); bw.Write(m_binaryData); bw.Flush(); bw.Close(); } }