我有发送图像到客户端(回传时)的HTTP处理程序:jQuery的Ajax调用HTTP处理程序(ashx的)
public class ImageHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
Byte[] pic = GetPhoto(Convert.ToInt32(context.Request.QueryString["userID"]));
if (pic != null)
{
context.Response.ContentType = "image/jpeg";
context.Response.OutputStream.Write(pic, 0, pic.Length);
}
else
{
context.Response.ContentType = "image/png";
context.Response.WriteFile("/AllImages/DefaultPicture_large.png");
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
我如何可以使用此处理将图像发送到客户端与jQuery ajax请求?
几个问题: 1)如何将图像转换为JSON? 2)如果无法将图像转换为JSON,我可以使用哪种格式将图像发送到客户端?
Tnx很多!
当然你是对的! TNX! – Sash