Click here to Skip to main content
15,909,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
Can anybody help me in displaying a tiff image in the browser without thumbnails

My code in default.aspx is
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Drawing.Imaging;

namespace Documentviewer1
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
            Response.ContentType = "image/tiff";
            string filename = HttpRuntime.AppDomainAppPath + @"\" + Request.QueryString["ImageFileName"];
            new Bitmap(filename).Save(Response.OutputStream,ImageFormat.Jpeg);
 }
    }
}

and I am using
HTML
<img src =" ~567892.tif alt width=200 height=200/>


and I am getting

An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Parameter is not valid.

what I am missing?

Can anybody help



Mary
Posted
Updated 22-Jan-14 3:31am
v4
Comments
Karthik_Mahalingam 22-Jan-14 9:33am    
<img src =" ~567892.tif alt width=200 height=200/>
this is just sample or u have code like this
Mary Abraham 22-Jan-14 9:51am    
I have code like this in the aspx page
Mary Abraham 22-Jan-14 10:38am    
Hi Karthik

I am getting parameter not valid error when debugging but the image is in image folder
where should I put the image

This is first time I am displaying tiff image

Can you help me. Also the tiff image consist of multipage
Karthik_Mahalingam 22-Jan-14 11:14am    
check my solutoin
Karthik_Mahalingam 22-Jan-14 11:45am    
create a folder in your web application name it as Images , place all your images in that folder
and write as
string appath = Server.MapPath("/Images") + @"\";

1 solution

Try to debug like this

modify your code in such ( not a big difference in logic )

C#
 string appath = HttpRuntime.AppDomainAppPath + @"\";
string imagename = Request.QueryString["ImageFileName"];
 string filename = appath + imagename; // apply break point on this line and check the file name path..
Response.ContentType = "image/tiff";
new Bitmap(filename).Save(Response.OutputStream, ImageFormat.Jpeg);


make sure that the image is present in the location. if the image is not available then this will throw the Parameter is not valid error.
and also check that the values is received from the query string...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900