How to add an image to an SSRS report with a dynamic url?

jrummell picture jrummell · Dec 2, 2009 · Viewed 35.8k times · Source

I'm trying to add an image to a report. The image src url is an IHttpHandler that takes a few query string parameters. Here's an example:

<img src="Image.ashx?item=1234567890&lot=asdf&width=50" alt=""/>

I added an Image to a cell and then set Source to External and Value to the following expression:

="Image.ashx?item="+Fields!ItemID.Value+"&lot="+Fields!LotID.Value+"&width=50"

But when I view the report, it renders the image html as:

<IMG SRC="" />

What am I missing?

Update

Even if I set Value to "image.jpg" it still renders an empty src attribute. I'm not sure if it makes a difference, but I'm using this with a VS 2008 ReportViewer control in Remote processing mode.

Update

I was able to get the images to display in the Report Designer (VS 2005) with an absolute path (http://server/path/to/http/handler). But they didn't display on the Report Manager website. I even set up an Unattended Execution Account that has access to the external URLs.

Answer

λ Jonas Gorauskas picture λ Jonas Gorauskas · Mar 26, 2010

I have a SSRS Report that displays the information about the countries of the users of a site that we support at work. This is based on the IIS log data. On this report, in the first column of the table is an image field that holds a small .gif of the flag for each country. I was running into the same exact issue described in the question above. The path to the external image was calculated in the report’s query based on the country code. I initially setup the URL to point to something like http://www.mystaticcontent.com/fotwimg/us.gif for a United States flag and so forth. All I got was a red X broken image displayed in the report. Then I found this MSDN article that shined some light on the issue for me.

This is what I did with the report to make it work:

  1. Moved the fotwimg folder that has all the gifs from the static content server to the local SSRS machine, which also has a web server running on it.
  2. Setup a virtual directory on the default web site in the local SSRS machine IIS Manager.
  3. Then I changed the report query to refer to the image in the local SSRS machine, by machine name, like this http://mylocalssrsmachine/fotwimg/us.gif
  4. Voila, it works… or at least it worked for me.