问题描述
我有一个图像存储在存储与检索我一次全部我的用户数据我的SQL Server数据库。
现在我有一个字节[]直接在页面上我想表明它。我怎么把我的WebControls.Image?我不希望有打电话给一个HttpHandler并再次调用数据库。
这显然只是其输出到整个页面。
Context.Response.BinaryWrite(user.Picture.ToArray());
如果这是你将它输出为base64 EN codeD数据成图像标签的小图像。
See这里有类似的情况。
但在任何情况下99.9%,您将创建一个返回图像的HttpHandler的。它是这样做,我认为最简单和最快的方式。
I have an Image stored in my SQL Server database stored with my User data which I retrieve all at once.
Now I have the byte[] directly on the page I want to show it on. How do I put it in my WebControls.Image? I don't want to have to call an HttpHandler and call the database again.
This obviously just outputs it to the whole page.
Context.Response.BinaryWrite(user.Picture.ToArray());
If it is a small image you would output it as base64 encoded data into an image-tag.See here for a similar situation.
But in 99.9% of all situations you would create a HttpHandler that returns the image. It is the easiest and fastest way to do it I think.
这篇关于在ASP.NET C#流字节[]到图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!