Response.OutputStream and file name RRS feed

  • Question

  • User-482944373 posted

    I'm using a HTTPHandler (cachedviews.axd)  to dynamically gerneate an image back to the browser.

    1. I getback a Bitmap from memory
    2. I set ContentType to "image/gif" for example
    3. I calle the Bitmap.Save(HttpContext.Current.Response.OutputStream, ImageFormat.GIF);

    The problem is that the filename being gerneated takes the HTTPHandler name. If I used this on several different images on the same webpage, I get back these images with the same name. I want to specificy my own name.

    So I'm wondering, how can I specific a filename with Bitmap.Save and at the same time, use OutputStream as well? I know Bitmap.Save() has an overload to save a filename to disk, but what about a file name to memoery?

    Thanks. really appricate it.
    Friday, March 31, 2006 4:59 AM

All replies

  • User-1372641848 posted

    Add "Content-Disposition" Header

    Response.AppendHeader("content-disposition", "filename=YourFileName.gif");

    Saturday, April 22, 2006 8:51 PM