我得到了一个返回图像的ashx"服务"。我是 ashx 文件的新手 - 所以不知道如何处理它。
我需要将图像流式传输到 byte[] 中,以便我可以将其复制到其他地方。我该怎么做?
您可以使用指向asxh的WebClient.DownloadData。
让我给你一个例子。假设您在页面上有图像 asp.net 如下所示:
<img src="http://someServer/someSite/MyHandler.ashx?id=myId"/>
在这种情况下,您可以使用以下代码:
using (System.Net.WebClient wclient = new System.Net.WebClient())
{
byte[] data = wclient.DownloadData(
"http://someServer/someSite/MyHandler.ashx?id=myId");
}
或者,您可以使用网络请求