0

我的处理程序有以下代码,我已经对其进行了调试,我可以看到我的图像变量 b 具有我需要的实际图像,但是我无法在浏览器中显示它。当我运行它时,我只是在屏幕上而不是图像上得到 System.Drawing.Bitmap。我不确定如何将其写入浏览器。任何想法将不胜感激,谢谢。

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://myaddress");
request.Credentials = new NetworkCredential("username", "password");
request.Method = "GET";
request.Accept = "image/jpeg";

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream s = response.GetResponseStream();
System.Drawing.Image b = System.Drawing.Image.FromStream(s);
context.Response.ContentType = "image/jpeg";
context.Response.Write(b);
4

1 回答 1

1

将其写入输出流:

b.Save(context.Response.OutputStream, ImageFormat.Jpeg);
于 2013-03-29T14:55:12.307 回答