Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Content-Disposition attachment not working in IE 7

Content-Disposition attachment not working in IE 7

Scheduled Pinned Locked Moved ASP.NET
helpgraphicssysadmin
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sudhirBirlapur
    wrote on last edited by
    #1

    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.

    S 1 Reply Last reply
    0
    • S sudhirBirlapur

      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.

      S Offline
      S Offline
      S Dhanasekaran
      wrote on last edited by
      #2

      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(); } }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups