【发布时间】:2012-03-23 11:32:48
【问题描述】:
我已将一个字节数组图像从 Web 服务加载到我的 asp.net 网站。 我需要在执行网络服务后立即将其显示在网页上。
我尝试过使用通用处理程序,但由于无法将 byte[] 图像传递给通用处理程序,所以我无法做到这一点
void Button2_Click1(object sender, EventArgs e)
{
this.verifyTemplates();
byte[] userImg;
try
{
matchTemp.templateService hs = new matchTemp.templateService();
bool s1 = hs.matchTemplates(template, out userID, out userName, out userImg);
// userImg is the byte image i need to display
}
catch(Exception exc)
{
// vLabel.Text = exc.Message;
}
}
【问题讨论】:
-
图片数据从何而来? “通用处理程序”代码在哪里?你到底想在点击事件处理程序中做什么?
-
请阅读 - Writing the perfect question。
-
忘记通用处理程序部分 button2 是一个 asp 按钮,在单击事件时,我执行了一个名为 matchTemplates 的 Web 服务,它给出的输出参数很少,最后输出参数是一个字节 [] 图像。我需要在页面上显示该图像
-
没有允许这样做的控件。您需要使用
image控件并将其源指向返回动态图像的HttpHandler。 SO上有很多问题和答案描述了如何实现这一目标。