我想使用Response.Write在HttpHandler上的网站上显示简单的单词,但这种简单的解决方案不起作用:
public void ProcessRequest(HttpContext context)
{
HttpResponse response = context.Response;
response.ContentType = "image/jpg";
Image Photo =
Image.FromFile("C:/Users/wiedy/Desktop/Obrazek.jpg");
var memoryStream = new MemoryStream();
Photo.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] bytes = memoryStream.ToArray();
byte[] image = bytes;
response.BinaryWrite(image);
response.ContentType = "text/plain";
response.Write("saddsadsadsadasdsa ");
}
图像正常显示。
我试图将ContentType更改为text / html,但这没有用,我也尝试使用BinaryWrite,但这也没有用
var stream = new MemoryStream();
var writer = new StreamWriter(stream);
writer.Write("Alodasdasdasdasdasdassssssssssdsadas");
writer.Flush();
stream.Position = 0;
byte[] alo = stream.ToArray();
context.Response.BinaryWrite(alo);
context.Response.Flush();
任何想法。
感谢您的帮助