Image Button and SaveAs

G

Guest

(appologies for re-post, but my no-spam alias was not configured correctly).

Hi,

I'm using VS2005 to create a web site.

On one of my aspx pages I have an ImageButton that displays an image that is
created in a seperate page.


ImageButton1.ImageUrl = "EmbeddedPage.aspx";

The EmbeddedPage.aspx generates the image to be displayed and returns the
image thus:

Bitmap image;
..
.. (image generated)
..
image.Save(Response.OutputStream, ystem.Drawing.Imaging.ImageFormat.Jpeg);

This all works fine except for one small problem. If the user right clicks
on the image, the file is saved with the .html extension and not .jpg. If
the extension is manually changed then the image will load correctly into an
image viewer, indicating that it is only the filename that is incorrect.

Can anyone suggest a solution so that 'save picture as' appends the correct
file extension.

Regards,
Dave.
 
W

Walter Wang [MSFT]

Hi Dave,

Thank you for post.

Have you tried to set the content type of Response object before calling
image.Save? For example:

Response.ContentType = "image/jpeg";
image.Save(Response.OutputStream, ImageFormat.Jpeg);

Hope this helps. If there's anything unclear, please feel free to post here.


Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top