I am trying to write a proxy server that reads an image from one server and returns it to the provided HttpContext, but I just return a stream of characters.
I am trying to do the following:
WebRequest req = WebRequest.Create(image);
WebResponse resp = req.GetResponse();
Stream stream = resp.GetResponseStream();
StreamReader sr = new StreamReader(stream);
StreamWriter sw = new StreamWriter (context.Response.OutputStream);
sw.Write (sr.ReadToEnd());
But, as I mentioned earlier, this is just an answer with text.
How can I say this image?
Edit: I am accessing this from inside the webpage in the original attribute of the img tag. Setting the content type to the application / octet stream prompt to save the file and attach it to the image / jpeg simply responds to the file name. I want the image to be returned and displayed by the calling page.
source
share