开发者

C# :How can i set Memory stream as the asp.net image control's source property?

I have an asp.net image control开发者_运维知识库 in one ASP.NET page and have a Memory Stream which has an image.How can i convert this memory stream to set it as the image source without storing the image in the hard disk ?


The image control takes an ImageUrl - a path to where the image is located.

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.

Here is an example for a general file handler using a memory stream - it's a good starting point for what I suggest.


you'll have to either write that file onto disk or make another page (action on the same page?) that writes the content of your MemoryStream into the Response, and then point the image control to that source.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜