[英]C# :How can i set Memory stream as the asp.net image control's source property?
我在一个ASP.NET页中有一个asp.net图像控件,并且有一个包含图像的内存流。如何在不将图像存储在硬盘中的情况下将该内存流转换为将其设置为图像源?
The image control takes an ImageUrl
- a path to where the image is located. 图像控件采用
ImageUrl
图像所在的路径。
There is no property that takes an actual image (or image data). 没有获取实际图像(或图像数据)的属性。
What you can do is write a HttpHandler
that will stream your images from whatever source - set the ImageUrl
to use this handler. 您可以做的是编写一个
HttpHandler
,它将从任何来源流式传输图像-设置ImageUrl
以使用此处理程序。
Here is an example for a general file handler using a memory stream - it's a good starting point for what I suggest. 这是一个使用内存流的常规文件处理程序的示例-这是我建议的一个很好的起点。
您将不得不将该文件写入磁盘,或者制作另一个页面(在同一页面上执行操作?)以将MemoryStream的内容写入Response,然后将图像控件指向该源。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.