R
rh1200la
Hey All. I'm trying to download an image from a URL and display it in
my page. I'm getting an error converting the Stream to Memory Stream.
I'm getting a Specified cast is not valid error for the line:
System.IO.MemoryStream MemoryStream =
(System.IO.MemoryStream)WebResponse.GetResponseStream();
Here's my code:
Response.Clear();
Response.ContentType = "image/gif";
System.Net.WebRequest ImageWebRequest;
ImageWebRequest = System.Net.WebRequest.Create(imgURI);
System.Net.WebResponse WebResponse = ImageWebRequest.GetResponse();
System.IO.MemoryStream MemoryStream =
(System.IO.MemoryStream)WebResponse.GetResponseStream();
MemoryStream.GetBuffer();
Response.BinaryWrite(MemoryStream.GetBuffer());
MemoryStream.Close();
Any ideas? Thanks.
my page. I'm getting an error converting the Stream to Memory Stream.
I'm getting a Specified cast is not valid error for the line:
System.IO.MemoryStream MemoryStream =
(System.IO.MemoryStream)WebResponse.GetResponseStream();
Here's my code:
Response.Clear();
Response.ContentType = "image/gif";
System.Net.WebRequest ImageWebRequest;
ImageWebRequest = System.Net.WebRequest.Create(imgURI);
System.Net.WebResponse WebResponse = ImageWebRequest.GetResponse();
System.IO.MemoryStream MemoryStream =
(System.IO.MemoryStream)WebResponse.GetResponseStream();
MemoryStream.GetBuffer();
Response.BinaryWrite(MemoryStream.GetBuffer());
MemoryStream.Close();
Any ideas? Thanks.