В настоящее время я работаю над школьным проектом, и я не уверен, что возвращается и как сделать данные пригодными для использования.Вот код:
Default.aspx
function GetImage(id) {
//step k. - code here
xmlHttpObj = CreateXmlHttpRequestObject();
if (xmlHttpObj) {
xmlHttpObj.open("GET", "Handler.ashx?id=" + id, true);
xmlHttpObj.send(null);
var image = document.getElementById("ProductImage");
//the response contains an array of 5419 index
}
}
Handler.ashx
public void ProcessRequest (HttpContext context)
{
int id;
if (context.Request.QueryString["id"] != null)
{
id = Convert.ToInt32(context.Request.QueryString["id"]);
context.Response.ContentType = "image/jpeg";
byte[] bufferImg = GetImage(id);
context.Response.OutputStream.Write(bufferImg, 0, bufferImg.Length);
}
}
GetImage (int id) возвращает "(byte []). Cmd.ExecuteScalar (); ", я не совсем уверен, что я должен делать с информацией, которая передается обратно.Я предполагаю, что это само изображение?любая помощь приветствуется.Спасибо!