views:

129

answers:

2

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 else.

Could not get any suitable way to do this.

Thank you in advance.

A: 

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: http://stackoverflow.com/questions/221925/creating-a-byte-array-from-a-stream

MrGumbe
yes, this will convert byte array to image stream and may be in image object but how to show that in webpage and how to assign it to Image control as it takes on image url.
BigBoss
This process is well documented here: http://stackoverflow.com/questions/887985/create-png-image-with-c-httphandler-webservice
MrGumbe
I guess I need to explain it better. I already have byte array or lets say image object. now I need to show that image in ImageControl in web page. I could not use HttpHandler as basiacally I might have to pass entire image as querystring.
BigBoss
So you have a byte array on the server side, but not in the handler itself. If that's the case, then I have a solution and I'll update my answer upon your verification.
MrGumbe
A: 

Hi guys,

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.

BigBoss