in

dotNetFreak

Ramblings & Controls from a .NET Addicted Freak!

Kevin Gearing's Blog

FormShield for .NET 2.0 Released

FormShield started out as a simple project with just one aim - to prevent automated form submission using dynamically generated images.

Not exactly a new idea - dynamically generated images requiring the user to enter the text found on the image have been around for quite a while, preventing automated sign-ups to free e-mail services such as HotMail and Yahoo, and automated whois lookups on domain names on sites such as Network Solutions.

Whilst some code exists on Code Project, there didn't however seem to be a free, easy-to-use and customisable control for ASP.NET with full designer integration that could generate the relevant images. So, looking for an excuse to delve into GDI+, FormShield was born and my idea of a 'simple' control was dropped...

... That was 2004 and this is now...

Version 2 of FormShield builds on the previous .NET 1.1 version, adding a wealth of new features, options and accessibility improvements. The most notable feature addition is the capability for FormShield to now automatically generate a spoken version of the value shown on the image to aid with accessibility legal compliance. This however is just one of a handful of major new features, not to mention the number of improvements and changes made since the previous version.

However, whilst a lot has changed, FormShield remains true to its original goals - to be 'easy-to-use', 'customisable' and to have 'full designer integration'.

No other .NET captcha control currently on the market has the number of features of FormShield, but more importantly, none of them are as customisable or have such a rich design-time experience when used in Visual Studio.

For more information, check out What's New in Version 2.0.


Features:

  • Generates BMP, GIF, JPEG or PNG images.
  • Choose the pixel format and smoothing mode used to render the image.
  • Set the height and width of the image as well as the alternate text displayed.
  • Image is built using 3 layers - Background, foreground and noise.
  • Provides 5 fill styles, 5 gradient styles, 54 hatch styles and 2 colors for each layer.
  • Set the length (static or random*) and case (lower, mixed or upper) of the automatically generated text.
  • Ability to set your own text for FormShield to use and the ability to regenerate or automatically change it on postback*.
  • Choose the type of characters you want to use to generate the text (alpha, numeric, symbols, a combination, or random).
  • Choose the fonts (when using a font based text effect) you want to use to draw the text (26 as default) as well as the font style (5 combinable styles, 17 in total).
  • Choose the default, static font to use to draw the text when not using a font based text effect*.
  • Pick a text effect (5 combinable effects, 25 in total) and decrease the noise level to decrease readability.
  • Draw a border around the image using one of 5 styles and your choice of color and width.
  • Randomise the fill style, gradient style, hatch style, font style, text case, character type, text effect and border style.
  • 6 Presets included; Default, Fire, Forest, Sand, Sea and ChessBoard.
  • Supports 4 persistent methods; ViewState, ControlState*, SessionState or HiddenField - ideal if ViewState and/or SessionState aren't available to persist property values on postback.
  • Values stored using any of the persistent methods are automatically encrypted for additional security (128 bit encryption*) with the ability to add your own key to the web.config file*.
  • ValidFrom and ExpiresAfter properties to set how many seconds have to pass before the image is valid and how many seconds after which the image has expired* - Prevent replay attacks.
  • ImageClick event raised when someone clicks on the image (supports Regenerate to generate a new value, BubbleEvent to bubble the event for custom handling or both)*.
  • Full embedded sound support (2 voices as standard, 8bit or 16bit and 8kHz or 16kHz - all selectable) - Will prompt to download the audio file if no plugin is installed.*
  • SoundLibraries distributed seperately so you only need to copy the one you require to your bin directory.*
  • Three additional icons rendered with customisable properties (AlternateText, Height, Width, IconUrl, Visible). Renders default icons if IconUrl is empty.*
  • Refresh icon to automatically regenerate the text value (can also raise an event for custom handling), Sound icon for built in audio playback and Help icon with customisable DestinationUrl property.*
  • Image and sound is rendered on demand (via an HttpHandler*), not saved as a file and audio files support caching (with an encrypted filename)*.
  • Encrypts the querystring (128 bit*) to prevent deciphering by reading the HTML source.
  • Works with existing ASP.NET validation controls as well as StringCompareValidator.
  • Can be used on standalone WebForms as well as UserControls.
  • Supports Community Server 2007* and .Text Blogging Engine to prevent spam on blogs.
  • Tested in IE6 & IE7 (PC), IE5 (Mac), FireFox 2 (PC & Mac), Safari 2 (Mac), Safari 3 (PC), Opera 9 (PC)*
  • Full, rich, Visual Studio .NET designer integration, including rendering whilst in design mode and menu options to automatically add configuration settings to the web.config file.
  • Works in a 'ViewState Disabled' environment. 
  • Compatible with Medium Trust environments*.

* New in Version 2.

Simple Online Demo (also see the comments section below)
 

Screenshots:

     


Design Time:


Properties Screenshot 1 | 2 | 3


Visual Studio .NET Design Time Notes:

  1. To get the image to appear when you first drag 'n' drop FormShield to your page, right click on the control and select both 'Add Secret Key' and 'Add HttpHandler', then save the file and right click on a blank space on the page and click 'Refresh'. If that doesn't work, hit the page in a Web browser and repeat the refresh process. You may also need to open, save and close the web.config file.

  2. On occasion the image doesn't reflect property changes made within the property grid. This seems to be either an issue with Visual Studio, or caching. The easiest way to solve the problem (if it happens in the first place) is to save the file and to repeat the refresh process described above. If you are changing image design properties you can also try placing your mouse cursor into the relevant dropdown list and use the cursor keys to navigate through the options.


Usage:

Simply download, add to your toolbox, drag 'n' drop to your page and set the relevant properties using the property grid.

To combine with a validation control (e.g. StringCompareValidator), add the validation control as well as a TextBox to your page, set the StringCompareValidator's 'ControlToCompare' property to point to the FormShield control and the 'ControlToValidate' property to point to the TextBox control. You will also need to set 'EnableClientScript' to False on the validator if 'EncryptQueryString' is set to True on the FormShield control.

To change the HttpHandler name/path, update your web.config file and change the HttpHandlerPath property value to point to the new handler.

To specify your own secret key for encryption, add/change the 'formShield_SecretKey' AppSetting in the web.config file.


Licensing & Download:

FormShield v2 is released as 'Donationware', for more information, please click here.

However - You don't have to donate unless you want to - FormShield can still be used for free for both personal and commercial use, however it will periodically (about 10% of the time) render 'dotNetFreak.co.uk' as the image text and will play 'This control is provided by www.dotnetfreak.co.uk' before the text value when someone clicks on the sound icon (again, about 10% of the time).

If you do decide to donate (thank you!), you will be e-mailed a license key as soon as possible with instructions on how to add it to FormShield so that it removes the 'dotNetFreak.co.uk' adverts.

Whether you have donated or not, you may also redistribute the control royalty free, providing that you don't charge for it. Also, if you intend to distribute the control as part of an application which is publicly available it would be nice to know, although this isn't a requirement.

Got a good image design? Drop me a line using the contact link and I'll look to include it as a preset. 

To download, please visit the 'Downloads' area.

 


Help & Support:

Please post in the forum.

 

Revision History: 

Updated 17/07/2007 (v2.0.1):

  • AddUpperLower property added to enable/disable the adding of 'Uppercase' or 'Lowercase' before each character when the sound is played.
  • MultiView design-time issue ('control collection cannot be modified during databind...') - Fixed.

To use this version you will also need to download v1.0.1 of the Sound Libraries.

Updated 13/07/2007 (v2.0.0):

Click here for the changes in this version. 

For the previous .NET 1.1 version, please click here.

Published Jul 13 2007, 10:02 AM by dotNetFreak
Filed under: ,

Comments

No Comments
Copyright ©2004-2007 Kevin Gearing. All Rights Reserved.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems