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.
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.
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.
A basic workflow for user interaction secured by Are You A Human directly utilizing the AyahServiceIntegration class:
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.
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();
}
}
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>
The AYAH .Net Integration Library assumes the following
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.
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.
If PlayThru isn't loading for you, please check the following:
If you need further support, head on over to our Support Center. We'd be more than happy to help you out!
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.