Amol Kolekar
Amol Kolekar

Reputation: 2325

Showing Tiff Images in Browser Using Response


I am having problem in displaying Tiff images in browser.I have my images stored in local folder.
I want to show them on browser and for that i am using Respose object.Following is my code.

Image img = Image.FromFile(Path);
img.Save(Context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png);

I am converting Tiff Image into Png format and showing it on browser,but it works only in IE.
In all other browsers it shows garbage values.I don't know why this is happening, Please help....

Upvotes: 1

Views: 1374

Answers (1)

leroy
leroy

Reputation: 26

A couple things you will need to do.

One is to set the content type for the Response, for PNGs set it to image/png. This will help the browser work out what kind of file it is and what to do with it. The other thing you might want to do is add a header for Content-Disposition to set a filename for the file, otherwise, if someone saves the file from the browser, it will use the name of the page that served the image.

Upvotes: 0

Related Questions