Search code examples
c#asp.neton-the-flywebresource

Embedding a Bitmap in ASP.NET's WebResource


I am generating a System.Drawing.Bitmap on the fly in an ASP.NET Custom Web Server Control, and then I want to serve this bitmap as part of the WebResource, because I do not want to save it on the hosting computer.

Is there a way to instruct ASP.NET to serve the generated System.Drawing.Bitmap as part of it's WebResource? (therefore making it an "Embedded Resource")


Solution

  • Use an HTTP Handler. The handler is basically a piece of code executed when a resource with a specified extension is requested from your server. Since you want a dynamically generated image, you would do that in the code for the handler and return it as a response. Embedding wouldn't work, because you can only embed static information. Here are some links: