page.aspx.cs 代码:
HttpContext.Current.Session["id1"] = id1.ToString();
Server.Transfer("Handler.ashx"); //Getting error
Image1.ImageUrl = "~/Handler.ashx?ID=" + id1.ToString();
HttpContext.Current.Session["id2"] = id2.ToString();
Server.Transfer("Handler.ashx"); //Getting error
Image2.ImageUrl = "~/Handler.ashx?ID=" + id2.ToString();
Handler.ashx 代码:
public void ProcessRequest(HttpContext context)
{
int id = Convert.ToInt32(context.Session["id1"]);
byte[] IMG = class.ReadImg(id);
context.Response.ContentType = "image/jpg";
context.Response.BinaryWrite(IMG);
}
public void ProcessRequest2(HttpContext context2)
{
int id = Convert.ToInt32(context2.Session["id2"]);
byte[] IMG2 = class.ReadImg(id);
context2.Response.ContentType = "image/jpg";
context2.Response.BinaryWrite(IMG2);
}
page.aspx 代码:
<asp:Image ID="Image1" runat="server" />//How to define thats gonna show image of id1
<asp:Image ID="Image2" runat="server" />//How to define thats gonna show image of id2
问题:
- 我无法将数据从 page.aspx 传输到 Handler.ashx
- 我不知道如何制作
Image
元素来根据 id 来识别它应该显示的图像(也许是一些request.queryString
我不明白的魔法)
帮助!!谢谢 :]