System.ApplicationException: Can't open image file

Hi,
This can’t get any more frustrating! Why am I getting error?

System.ApplicationException: Can't open image file http://localhost/folder/ImageHolder.aspx?QID=1&UserValues=1.3,1.7,1.9,4.9&charttype=Standard

I have an image tag in the xml

<Image Type=“Jpeg” ID=“Chart1” > </Image>

I assign an image to the tag with the following statements

string strURL = “http://localhost/folder/ImageHolder.aspx?QID=1&UserValues=” + val4 + “,” + val3 + “,” + val2 + “,” + val1 +"&charttype=Standard";

ChImage2.ImageInfo.File = strURL;

The above mentioned URL returns an image file of type Jpeg. But, when I execute the application, I get the Can’t open image file error.If I execute the URL seperately, the other application generates the image perfectly.

Please help me as I am loosing my patience.

Jai

Dear Jai,

Thank you for considering Aspose.

I have reproduced this error. I use the following code to get Bitmap and it fails:

WebRequest webrq = WebRequest.Create(url);
img.ImageBitmap =
(Bitmap)Bitmap.FromStream(webrq.GetResponse().GetResponseStream());

I will study this issue and try to solve this problem. If you know how to get the Bitmap, please tell me.

Dear Jai,

In my further test I found there is no problem. Here is the XML I used for test:

http://localhost/WebApplication1/GetImage.aspx" Type="jpeg" ImageScale="0.6">


And here is the code of the GetImage.aspx:
System.IO.FileStream fs = new System.IO.FileStream("D:/share/apple.jpg",System.IO.FileMode.Open);
fs.Position = 0;
byte[] buf = new byte[fs.Length];
fs.Read(buf,0,(int)fs.Length);

Response.AddHeader("content-disposition","inline; filename=test.jpg");
Response.ContentType = "image/jpeg";

Response.BinaryWrite(buf);
fs.Close();
Response.End();

So can you please give me a url that can reproduce this erro? Or some code that can build a aspx locally?

Hi

I appeciate your help. Actually, the problem was, I have not provided access to the file without log on in the web.config file. Since our site is a protected web site, all users have to log on first.

Now, I have exempted this file from authorization and it's working fine.

Thanks for your help

Jai