开发者

dynamic image control

I am getting dynamic image in form of byte array. and i want to show that in webpage, preferably ImageControl

I am aware of method of creating http handler and getting image stream. but I cant do that here as logic for same is performed somewhere e开发者_如何转开发lse.

Could not get any suitable way to do this.

Thank you in advance.


You can still convert your byte array to a stream in your handler and send the bytes as normal. Here's a good post on how to do that: Creating a byte array from a stream


Finally I took middle approach.

I am having image object in code behind. For shwoing that in main web page.

I am adding that object in Cache with one random key (in my case GUID). Then I am generating URL such as ~/GetImage.ashx?id=[GUID]

When this URL is accessed an image from cache will be stored.

Note:

  1. I am adding image to cache with self expiration set to absolute 2 mins. to ensure cache will be empty without manual intervention and there is enough time for other processing to happen.
  2. Used Cache over Session for same reason mentioned in point 2, where i may have to manually remove it.

Of course I am still open for better solution.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜