1

first of all, sorry for my english

I'll try to explain my problem:

1st) Server retrieve an image from Database, in the Database i've only the path, then i encapsulate the image in a XML and i send this XML to the client.

2nd) The client decapsulation the img, so the client has an array of bits with the image. it's not allow send the path for security.

Now i need associate this image with my webcontrol img.

i do something like

ImgUrl = "Handler.ashx?num_doc=13"

and it works, but really i need do something like:

ImgUrl = "Handler.ashx?num_doc=" + num_doc;

where num_doc it's a http parameter recieved from a page. I'll try to put the ImgUrl from code but it doesnt work, just show a path.

Thank u

Fesioche
  • 11
  • 1

1 Answers1

2

There is a possible solution to your problem:

Encode the image bits as base64 string:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA..."" alt=""/>

The way to do it is when you call your handler you will get a json string representing the content of the image. You would never have to worry about security since no paths are actually shown and the image itself is embedded in the string returned by your handler.

To do so you can read all bytes of the image, and then use Base64Encoding to convert the byte array to string. Return the string with

"data:image/[mime type]; base64,"

pre appended to it.

Returning the XML with a reference to an image will never work because <img> tag always expect a src property, where the src property is the path of the image. If you need to hide the paths this is your only chance.

Check this page for help: Grey WyVern.com

bleepzter
  • 9,607
  • 11
  • 41
  • 64