This is pretty complicated so I will explain what is going on.
I have created an ASP.NET website for displaying images, the way we use our images is, we have a database table that contains the URL where the images are located, however we recently started moving them from the filesystem, and storing them directly into the database as binary, but since we don't want to break older applications, we currently store them both places till they are all updated.
Alright, the website I'm working on, is just a reporting website to display images by a date range, I have created an HTTPHandler to display the image, depending if they exist in the database as binary, if the row is DBNull, I just grab the URL from the other table instead, I just read the image, convert it into a byte[] and write it to the response, so it is interpreted as an image.
I have created a page to display the report using DevExpress Reporting, I just query the report, save the dataset into a session, and the report reads the session to bind the report, i also have a picturebox in the report bound to "Handler.ashx?id=ImageID", this is because I am not binding a URL to the image, since it is a byte[]
Also since there could be a report with 10000+ images, I am reading the dataset from the session inside the handler and just pulling out the image from the passed in ImageID, I am doing this to prevent connecting to the database each and every row.
Now the strange thing is, Report loads fine.. data is loading, I have paging on the devexpress report viewer, it is loading the images fine, however here is the issue.
When I print or export, I am not getting any images, I am debugged and found out the Session.Count is 0 when it tries to print or export, which is strange since there is more than just the dataset in the session. I have also added IRequiresSessionState to allow sessions in the handler, but the session count is still 0, I have changing the Handler to an aspx page, same issue.
Any ideas or suggestions on logic changes, I'm all ears.. this is a very difficult situation since I have to display the images from database as a string AND byte[] since one can be URL and other be the image bytes, but I also can't slam the database on connection calls each row either.
I have also reported the issue to DevExpress and they are clueless as well, since they don't dispose the session in the exporting process.