This is a question about something that I've been wanting to do, but not something I desperately need. I've been writing a number of asp.net projects that needed dynamically generated images. I've just been using an aspx for this, but clearly there has to
be a more elegant solution. Ideally, I could package the whole thing in a custom server control, both the linking and the generating. The scenario would be approximately:
<div mce_keep="true">On the page I put something like <menno:DynamicImage Text="Some text for my image" runat="server" /></div>
<div mce_keep="true">My server control registers a handler that will return my generated image, gets a url for it</div>
<div mce_keep="true">My server control renders <img src="handlerurl" /></div>
Pretty much I need a webresource.axd for dynamic images. How would I go about doing this? Is there a way to assign a delegate to a handler? Has anyone done this before?
Pretty much I need a webresource.axd for dynamic images
From your description, it seems that you want to use webresource to show your images dynamically, right? WebResource.axd is a special handler in ASP.Net. In your scenario, you can create an HttpHandler to match your requirement. In your handler, you can
recieve a parameter which stands for the resourceid you want to get, and then, print out the image directly from the handler, here's an sample on how to achieve that.
Menno van de...
Contributor
2764 Points
391 Posts
Dynamic image control
Feb 02, 2009 08:45 AM|LINK
Hi,
This is a question about something that I've been wanting to do, but not something I desperately need. I've been writing a number of asp.net projects that needed dynamically generated images. I've just been using an aspx for this, but clearly there has to be a more elegant solution. Ideally, I could package the whole thing in a custom server control, both the linking and the generating. The scenario would be approximately:
Pretty much I need a webresource.axd for dynamic images. How would I go about doing this? Is there a way to assign a delegate to a handler? Has anyone done this before?
Thanks,
Menno
Nai-Dong Jin...
All-Star
41630 Points
3558 Posts
Re: Dynamic image control
Feb 06, 2009 03:43 AM|LINK
Hi,
From your description, it seems that you want to use webresource to show your images dynamically, right? WebResource.axd is a special handler in ASP.Net. In your scenario, you can create an HttpHandler to match your requirement. In your handler, you can recieve a parameter which stands for the resourceid you want to get, and then, print out the image directly from the handler, here's an sample on how to achieve that.
http://www.c-sharpcorner.com/UploadFile/desaijm/HTTPHandlersForImages11152005062705AM/HTTPHandlersForImages.aspx
Thanks.