.Net Library Installation Instructions

Downloads

Download .Net 3.5 Files Download .Net 4.0 Files

We have created a sample project for you to use as a starting point for implementing the Are You a Human plugin. It was kindly provided by Joseph Klecha.

Download Sample Project

Description

The Are You a Human (AYAH) PlayThru solution is designed to be easily implemented in any ASP.net environment to secure individual POST or GET requests. There are two methods available for integrating your web application: using the provided ASP.Net Web Forms control, or by using the integration class, AyahServiceIntegration, which communicates with Are You A Human via web service calls.

The AYAH .Net library is provided as the compiled library AreYouAHuman.dll. Once you have downloaded the library, add a reference for your project to this DLL to begin using AYAH. Using Visual Studio, select 'Add Reference' from the Project menu. On the .NET tab of the resulting dialog, select Are You A Human from the list of .Net components and click OK. If the AYAH library is not listed, use the Browse tab to manually select the library from its location on your computer.

ASP.Net Web Forms Control

To utilize the AYAH ASP.Net Web Forms control, begin by adding the control to the Visual Studio Toolbox. When viewing a page in design mode, you can add the AYAH control by right clicking on the toolbox, selecting "Choose Items.." and checking the item 'AyahControl' associated with the Are You A Human assembly. Once the item is available in your toolbox, you can add it to a ASP.Net page by dragging and dropping from the toolbox onto either the designer surface or the source markup file.

To utilize the AYAH control to secure the desired page, simply access the built-in page validation by checking the Page.IsValid property before completing the action you want to secure. If the property is true and the user can proceed to the secured action, call the RecordConversion() method before proceeding.

Direct Integration

A basic workflow for user interaction secured by Are You A Human directly utilizing the AyahServiceIntegration class:

  • Start by creating a new instance of the AyahServiceIntegration class
  • When you serve content to be secured, generate and insert an HTML block to be included in the output. This is done by calling the GetPublisherHtml() method and outputting the returned string.
  • When you receive the content in a form submission or other access that should be secured, verify that the PlayThru was passed by the website visitor. This is done by calling ScoreResult(), which returns a Boolean true on success and false on failure.
  • To record a conversion and indicate that a user has successfully completed the PlayThru, call RecordConversion() after receiving a completed form submission and getting a true value from ScoreResult.

Publisher Keys

You will be provided a publisher key -- a random string that is used to uniquely identify you -- from areyouahuman.com. This key is associated with a particular PlayThru. Contact us if you would like to customize your PlayThru or conduct A/B testing on verification options. Your publisher key can be specified in your integration code in one of two ways.

  • By specifying the key using your project's Web.Config file: add a key to the appSettings section of the web.config file using the key name "AyahPublisherKey" and the value as the provided publisher key
  • By passing the publisher key to the appropriate method as needed: a GetPublisherHtml overridden method is available that takes the publisher key as a parameter.

Sample Code (ASP.Net Web Forms Control)

The following is a simple implementation:

<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="Default.aspx.cs"
Inherits="Default"%>
<%@RegisterAssembly="AreYouAHuman"Namespace="AreYouAHuman"TagPrefix="ayah"%>
<html>
<head>
<title>AYAH ASP.Net Sample </title>
</head>
<body>
<formid="form1"runat="server">
<div>
<asp:LabelID="MessageLabel"runat="server" Text="Complete the game below to continue:"></asp:Label>
<ayah:AyahControlID="Captcha"runat="server" PublisherKey="YourPublisherkeyGoesHere"ShowFailureMessage="true"/>
<asp:ButtonID="SubmitButton"runat="server"Text="Submit" OnClick="SubmitButton_Click
"/>
</div>
</form>
</body>
</html>

The associated code behind would be as follows:

publicpartialclassDefault : System.Web.UI.Page
{
///<summary>
/// Checks the validity of the page and proceeds accordingly
///</summary>
privatevoid CheckResults()
{
if (Page.IsValid)
{
//record conversion
Captcha.RecordConversion();
//if valid, go to next page!
Response.Redirect("Success.aspx");
}
else
{
MessageLabel.Text = "Sorry - You did not prove to be a human.";
}
}
protectedvoid SubmitButton_Click(object sender, EventArgs e)
{
CheckResults();
}
}

Sample Code (Direct Integration)

Assuming the associated code behind file contains the following definition ..

protectedAyahServiceIntegration AyahDirect = newAyahServiceIntegration();

the following is a simple implementation:

<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="DirectExample.aspx.cs"
		Inherits="DirectExample" %>
<html>
<head>
<title>AYAH ASP.Net Sample</title>
</head>
<body>
<formid="form1"runat="server">
<divid="ayahDiv">
<%
if (this.IsPostBack)
{
string sessionSecret = this.Request.Form.Get("session_secret"); if (AyahDirect.ScoreResult(sessionSecret))
{%>
<
%AyahDirect.RecordConversion(sessionSecret); %>
<h3>Congratulations - you ARE a human!</h3>
<%}
else
{%>
<h3>Sorry - you did not prove to be a human.</h3>
<%}
}%>
<%=AyahDirect.GetPublisherHtml()%>
<inputtype="submit"value="Click me when you're done to see if you are human!"/>
</div>
</form>
</body>
</html>

Let's review the salient lines of the above example:

string sessionSecret = this.Request.Form.Get("session_secret");
if (AyahDirect.ScoreResult(sessionSecret))
{%>
<%AyahDirect.RecordConversion(sessionSecret); %>
<h3>Congratulations - you ARE a human!</h3>
<%}
else
{%>
<h3>Sorry - you did not prove to be a human.</h3>
<%}

Here, if the form is submitted (the example submits to itself), we score the result and display a message according to whether or not your PlayThru judges the website visitor to be a human.

<%=AyahDirect.GetPublisherHtml() %>

And, of course, you output the HTML.

To specify your publisher key via Web.Config:

<?xmlversion="1.0"?>
<configuration>
<appSettings>
<addkey="AyahPublisherKey"value="YourKeyValueGoesHere"/>
</appSettings>
</configuration>

General Requirements

The AYAH .Net Integration Library assumes the following

  • You can make calls to port 443 on the AYAH web service, ws.areyouahuman.com

If you have an internal firewall or other protection against placing web service calls from a ASP.Net code executed from your web server, please permit calls to ws.areyouahuman.com.

Versioning

The AYAH .Net Integration Library is available for download in separate builds for compatibility with the Microsoft .Net Framework versions 3.5 and 4.0 respectively. The version 3.5 build references .Net Framework core libraries v2.0 as well as the v3.5 extensions, allowing this version to run on IIS hosted ASP.Net Web Applications at version 2.0 configuration as long as the required extensions are installed. To run on an IIS hosted site at version 4.0 configuration, use the AYAH v4.0 download. There is not a compatible download for running websites using .Net Framework v1.1 configuration.

Troubleshooting

If PlayThru isn't loading for you, please check the following:

  • If PlayThru is set to "Lightbox" mode, it will only display once the form it's included in has been submitted. You can see which mode PlayThru is set to in the "Game Style" section of the Dashboard.
  • Make sure that you are using the correct publisher key and scoring key.
  • Check to see if your server and/or network has a firewall which prevents outbound connections via port 443.

If you need further support, head on over to our Support Center. We'd be more than happy to help you out!

Installation Support

If you run into any issues during your installation process please use our support forums. We appreciate all feedback and are ready to help! Follow us on Twitter and Facebook for PlayThru™ updates.