I dug something else up while doing some cleaning : a captcha control. The core functionality is taken from
this codeproject article. I've gone ahead and wrapped it in a custom server control as well as taking advantage of HttpHandlers.
This was actually incorporated into a bigger library, so I had to rework some stuff to make it more stand-alonish. I also noticed that I could have exposed more properties to make it more flexible - oh well.
Since it makes use of HttpHandlers and custom server controls, I think it really highlights some of the best tools ASP.NET offers when it comes to reuse. Sure it might seem like a lot of code, but it's contained set of code which is ready to be reused in any projects - write once, reuse often. (That said, I'm not actually including a .dll file (just the source), because I don't want to give anyone the impression that it's a solid 3rd party control.)
To set it up, add the 4 .cs files to your App_Code folder (or a separate project). Add these line to your web.config's system.web element:
<httpHandlers>
<add type="Fuel.Web.CaptchaHandler, App_Code" verb="GET" path="captcha.ashx" />
</httpHandlers>
And then Register the namespace:
<%@ Register Assembly="App_Code" Namespace="Fuel.Web" TagName="Fuel" %>
All you need to do then is use the control:
<Fuel:Captcha runat="Server" />
If you aren't using 2.0, or aren't placing these in your App_Code folder, simply replace "App_Code" with the name of the .dll it'll get compiled to.
Finally, if you are using 2.0, don't forget that you can register controls site-wide now via:
<pages>
<controls>
<add assembly="App_Code" namespace="Fuel.Web" tagPrefix="Fuel"/>
</controls>
</pages>in system.web of the web.config
Download it here