ASP.Net AJAX NoBot Extender Control Example

Updated on 07 Jul 2009, Published on 16 Sep 2008

ASP.Net AJAX NoBot extender Control returns different types of responses when a user sends a request and ASP.Net web page performs postback. Each type of response has its different description based on the different types of activity factors of a user browsing the web page and submitting a web form. AJAX NoBot extender control checks all the behaviors and detects whether the action is being performed by the human or automated software. AJAX NoBot control caches the IP address of the client and counts the number of postback of a single APS.Net web page.

AJAX Control Toolkit Examples:

You can see the live samples and examples of AJAX Control Toolkit from the following links:

If a user sends number of requests within a specified CutOffWindowSeconds without obeying the ResponseMinimumDelaySeconds, then it is considered as Bot. Following are the different types of AJAX NoBot control responses:

Valid: When NoBot control verifies the actions performed by a user and it passes all the tests then the user is considered as human.

InvalidBadResponse: When challenge script fails the test then AJAX NoBot control returns the bad response. 

InvalidResponseTooSoon: When postback occurs more quickly than a specified ResponseMinimumDelaySeconds.

InvalidAddressTooActive: When a single client’s IP remains active for a long time and performs number of postback then it returns the InvalidAddressTooActive.

InvalidBadSession: When ASP.Net Session State becomes unusable.

InvalidUnknown: When unknown problem occurs.

Example of ASP.Net AJAX NoBot Extender Control

 

HTML Code

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

<asp:Label ID="Label1" runat="server" Text="NoBot Response State:" Font-Bold="true" Font-Size="14px"></asp:Label>
<asp:Label ID="Label2" runat="server" Font-Size="16px"></asp:Label>

<div class="clear"><br /></div>

<asp:Label ID="Label3" runat="server" Text="Client IP Address:" Font-Bold="true" Font-Size="14px"></asp:Label>
<div class="clear"></div>
<asp:Label ID="Label4" runat="server" Font-Size="16px"></asp:Label>

<div class="clear"><br /></div>                
<ajaxToolkit:NoBot
    ID="NoBot1"
    runat="server"
    CutoffMaximumInstances="5"
    CutoffWindowSeconds="60"
    ResponseMinimumDelaySeconds="2"
    OnGenerateChallengeAndResponse="NoBot1_GenerateChallengeAndResponse" />
    
<asp:Button ID="Button1" runat="server" Text="Check Spam" OnClick="Button1_Click" />
 

C# Code

protected void Button1_Click(object sender, EventArgs e)
{
    NoBotState state;
    // if condition to check the response state of NoBot
    if (NoBot1.IsValid(out state))
    {
        Label2.Text = state.ToString();
    }
    else
    {
        Label2.Text = state.ToString();
    }

    StringBuilder sb = new StringBuilder();

    // foreach loop to get cached IP address and datetime assocated with it(when last postback was occurred)
    foreach (KeyValuePair<DateTime, string> keyValue in NoBot.GetCopyOfUserAddressCache())
    {
        sb.AppendFormat("{0}: {1}<br />", keyValue.Key.ToString(), keyValue.Value);
    }

    Label4.Text = sb.ToString();
}

Output:

You can see the output of above discussed code from the following link:

AJAX NoBot Control

Continue to next tutorial: ASP.Net AJAX Password Strength Extender Control to learn the functionality for displaying the CSS based indicator showing the password strength.

0 Responses to "ASP.Net AJAX NoBot Extender Control Example"
Leave a Reply

Name   (Required)


Mail   (will not be published) (Required)


Website   (http://www.example.com)




OR Subscribe via Email: