How Do I...

Important: This documentation applies to 1.0 only. The 2.0 documentation is here

configure my ASP.NET 2.0 website to use AIP?

  1. Open your web.config file. If you don't have one, create one (In Visual Studio 2005 add a new item to the project and select Web Configuration File as its type).
  2. Add the xml in Figure 1 to your web.config file.

use the AIP web control in my Visual Studio 2005 Web Site project?

You can add the AIP web control to a web form in Design view using the toolbox, or in Source view by declaring the control in HTML.

Add the AIP web control to Visual Studio's Toolbox
If you have successfully installed the AIP web control into Visual Studio 2005 using the AIP Installer then you do not need to follow these instructions; otherwise, follow these instructions so that you can drag and drop the AIP web control from the toolbox to your web form:
  1. Open the Toolbox in Visual Studio 2005.
  2. Create a new tab and name it DaveSexton.Web.Controls.
  3. Right-mouse click the empty area under the tab and select Choose Items....
  4. In the Choose Toolbox Items dialog select the .NET Framework Components tab and click Browse....
  5. Browse to the AIP installation directory, commonly found at C:\Program Files\Dave Sexton\AIP, and then open the bin folder.
  6. Select DaveSexton.AutoInputProtection.dll and click Open.
  7. Make sure that three controls with names that start with AutoInputProtection are added to the list and that they are checked.
  8. Click OK.
Add the AIP web control to a web form in HTML view
If you'd prefer to add the AIP web control to your web form without using a designer:
  1. Open your web form in Source mode (HTML).
  2. Add the declaration in Figure 2 to your web form next to the other declarations at the top of the page.
  3. Add the XHTML in Figure 3 to your web form, wherever you'd like the control to be placed.
  4. If your project doesn't reference the AIP assembly then you should do that now (see the next topic).
Reference the DaveSexton.AutoInputProtection assembly
If you have successfully installed the AIP web control into Visual Studio 2005 using the AIP Installer then dragging one of the AutoInputProtection controls from the toolbox into a designer will automatically add a reference to the AIP assembly. To add a reference manually:
  1. In Solution Explorer, right-mouse click the project and select Add Reference...
  2. In the Add Reference dialog, select the Browse tab.
  3. Browse to the AIP installation directory, commonly found at C:\Program Files\Dave Sexton\AIP, and then open the bin folder.
  4. Select DaveSexton.AutoInputProtection.dll and click OK.

choose the default text and bitmap providers for my website?

After you have added the basic AIP configuration elements to your web.config file, you may want to configure your website to use a different text provider or bitmap provider.

To specify a default text provider and bitmap provider you must register the providers and use the defaultTextProvider and defaultBitmapProvider attributes, respectively, to assign them as the defaults.

See Figure 4 for an example configuration file that registers a default text provider and a default bitmap provider.

Note: Once the autoInputProtection section is added to the web.config file you must specify a default text provider and a default bitmap provider or an exception will be thrown at runtime stating that a default provider is not configured.

For more information about providers see AIP Providers.

configure my website to use an AIP filter provider?

After you have added the basic AIP configuration elements to your web.config file and configured a default text provider and bitmap provider, you may want to add filters to help randomize the output. AIP comes with one built-in filter that renders translucent bars, vertically or horizontally, over the image generated by the bitmap provider that you configured. This particular filter is only applied after the text is drawn on the bitmap.

To configure a filter in your application:
  1. Add the xml in Figure 5 to your web.config file.
  2. Configure the filter using XML attributes. The colors attribute is required for the filter provider used in the example, TranslucentBarsOverlayAutoInputProtectionFilterProvider.
Every filter that is configured will be applied. The order in which the filters are added to the filters configuration element, top-down, is the order in which they will be executed at runtime.

See AIP Providers, Filter Providers for more information about filter providers.

create a custom AIP text provider?

To create a custom text provider you must create a class that derives from the DaveSexton.Web.Controls.Configuration.AutoInputProtectionTextProvider class, directly or indirectly.

The example in Figure 6 shows a fully functional text provider class named, RandomNumbersAutoInputProtectionTextProvider, written in C#, that will generate random numbers.

For more information about text providers see AIP Providers, Text Providers.

create a custom AIP bitmap provider?

To create a custom bitmap provider you must create a class that derives from the DaveSexton.Web.Controls.Configuration.AutoInputProtectionBitmapProvider class, directly or indirectly.

The example in Figure 7 shows a fully functional bitmap provider class named, WhiteBackgroundAutoInputProtectionBitmapProvider, written in C#, that will render the background of an AIP image as solid white.

For more information about bitmap providers see AIP Providers, Bitmap Providers.

create a custom AIP filter provider?

To create a custom filter provider you must create a class that derives from the abstract DaveSexton.Web.Controls.Configuration.AutoInputProtectionFilterProvider class, directly or indirectly. The example in Figure 8 shows a fully functional, post-process filter provider class named, CrossHatchAutoInputProtectionFilterProvider, written in C#, that will render a diagonal cross hatch over the composite image. The composite image is the background bitmap that is supplied by the configured bitmap provider with the validation text generated by the configured text provider rendered on top.

To create a custom filter that processes the bitmap before the text is rendered, override the CanPreProcess property and return true in your custom filter provider class. Then, override the PreProcess method and provide your implementation.

For more information about filter providers see AIP Providers, Filter Providers.

Last edited Apr 2, 2008 at 12:10 PM by davedev, version 9

Comments

No comments yet.