Setting Response.ContentType = "image / tiff" in asp.net 1.1 and IE7 does not render tif files

I have an Asp.Net 1.1 application that uses the following code to output an image file to a popup web page.

    Response.ContentType="image/tiff"   'Only for Tif files
    Dim objStream As Object
    objStream = Server.CreateObject("ADODB.Stream")
    objStream.open()
    objStream.type = 1
    objStream.loadfromfile(localfile)
    Response.BinaryWrite(objStream.read)

      

I am testing this with TIF files. The files are displayed correctly in IE6 and Safari, but they are not displayed in IE7 and nothing seems to return to the webpage. Files with jpg, gif extensions are displayed correctly. What could be the problem here?

0


source to share


3 answers


Well, it depends on your audience. But ideally, to support legacy browsers, you shouldn't assume they can handle TIFF.

At least load the TIFF, select the first frame (page), draw a DrawImage to a new bitmap, save the bitmap as a JPG on a memory stream and send it in response.

If you are not familiar with .NET GDI + image processing, or if it sounds complicated, go to http://www.bobpowell.net/faqmain.htm for advice . Each of these steps can be completed with just a few lines of code. If you don't already know GDI +, you should study any web developer. It can do it in a "hard (but safe) way" that is worth it for education alone. And if you already know how to do it, it only takes half an hour.



If you have to display multi-page TIFFs and you want the user to have control over which pages to see, you will need to create a UI to set the page number. If you are trying to display multiple TIFFs on a page this can get nontrivial, so consider displaying all tiff # 1 pages on the first web page, or letting them view subsequent TIFF pages by linking to another web page with prev / next tiff page buttons. This should be a generic page that accepts the filename and current page numbers (previous / next buttons point to themselves with +/- one page number) as URL parameters.

If you know you will only show text documents instead of photos, try sending only single-frame GIFs instead of TIFFs to the browser to reduce the Jpegginess text. But beforvarned - photos can look pretty bad GIFs.

+1


source


Have you tried setting Content-Disposition to Inline?



Response.AppendHeader("Content-Disposition", "inline");

      

0


source


Yes, I tried it now. Does not work. It has something to do with the tiff with 4 letters instead of 3. I read somewhere that IE7 doesn't support 4 letter extensions.

0


source







All Articles