I've got an ASP.NET application with a library that generates an Image. It is set up as follows:
In the Web.config I have a declaration in the <httpHandlers> section like so:
<add path="My.image.aspx" verb="GET" type="MyProject.Handlers.MyImageHandler, MyProject" validate="false"/>
This links up the code to generate the image to that path which is then used on my .aspx page like this:
<asp:Image ImageUrl="My.image.aspx" BorderWidth="0" ID="myImage" runat="server"/>
When viewing this page normally, the image is loaded correctly.
However, I need to output this image to a PDF file, but because the PDF's won't interpret the page HTML with that URL correctly (says it cannot find resource, because these files are limited to interpreting only basic HTML/CSS), I wanted to try to load the Image in the code behind and output it to the PDF that way. However, I have no idea how to load this image in the code behind. I tried the following:
System.Drawing.Image img = System.Drawing.Image.FromFile("My.image.aspx");
But had no luck. Is there a proper way to load this Image in the code behind from the httpHandler I have specified?
EDIT: I found a workaround, as I couldn't get the Image to load from the code behind. Instead, I have just used the <asp:Image> control to the load the file on the page and trigger the handler. When the handler creates the System.Drawing.Image file I was able to add it to the Session object for use later on that page. However, I still was unable to find a way to trigger all of that from the code behind without using a front end ASP control.