Q:

Strange chars on ColorBox on image from Webapi

i'm creating a image galery with jquery colorbox plugin and for images i'm using the asp.net webapi to manipulate sizes and crops.
My problem occurs when i click on the thumbnail, and the box tha is opened does not display the image i whated but a lot of strange chars inside the box, as im loading a flat text file instead of a image.
any idea what i'm doing wrong?
Thats the code:
<a class="gal_4" href="/api/CDN/GaleryImage/25" rel="image"><img src="/api/CDN/GaleryThumbnail/25" alt="" /></a>
<script>
    $(function () {

        $(".gal_4").colorbox({ rel: 'gal_4' });

    });
</script>

and for the webapi who produces the returned image:
HttpResponseMessage rv = new HttpResponseMessage(HttpStatusCode.OK);
MemoryStream oMS;

... Load image byte array on Memory stream ...

rv.Content = new ByteArrayContent(oMS.ToArray());
rv.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpg");

return rv;

when i point the src attribute of an image tag in my html it works very well, but not with colorbox, any idea?
thanks in advance for your help

A:

Try use photo property
If true, this setting forces Colorbox to display a link as a photo. Use this when automatic photo detection fails (such as using a url like 'photo.php' instead of 'photo.jpg')
Similar question: Problem while working with Jquery colorbox and dynamic images that reading via Aspx

