articles

Home / DeveloperSection / Articles / Ajax Toolkit NoBot Control in ASP.Net

Ajax Toolkit NoBot Control in ASP.Net

Pushpendra Singh20991 07-Dec-2010

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. A great feature of the NoBot control is its invisibility.

NoBot Properties:

·         ResponseMinimumDelaySeconds - minimum number of seconds before which a response (postback) is considered invalid.

·         CutoffWindowSeconds - Optional number of seconds specifying the length of the cutoff window that tracks previous postbacks from each IP address.

·         CutoffMaximumInstances - Optional maximum number of postbacks to allow by a single IP addresses within the cutoff window.

·         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.

Code:

Write these codes on aspx page

 <%-- ScriptManager control manages client script for AJAX enabled ASP.NET pages.This enables partial-page rendering and Web-service calls.You have to used this if you want to use ajax control toolkit--%>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<%-- Add NoBot Control--%>
 
<cc1:NoBot ID="NoBot1" runat="server" Enabled="true" CutoffMaximumInstances="1" CutoffWindowSeconds="2" ResponseMinimumDelaySeconds="5" />
<%-- Add Panel and some control--%>
 
<asp:Panel ID="Panel1" runat="server">
<asp:Label ID="Label1" runat="server" Text=" User Id"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Text="Id"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="Password"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" Text="12"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:Label ID="Label3" runat="server" Text=""></asp:Label>
<asp:Label ID="Label4" runat="server" Text=""></asp:Label>
</asp:Panel>

 

Here ResponseMinimumDelaySeconds="5" indicate that user should submit form after 5 second and if user click before 5 second then error message will show.

Write these code on Button1 click

protected void Button1_Click(object sender, EventArgs e)
{
      NoBotState state;       
      if (NoBot1.IsValid(out state)) //Check the condition is valid or not
            Label3.Text = state.ToString();     
      else            
Label3.Text = "Page not valid";
         
StringBuilder sb = new StringBuilder();//Make the object of StringBuilder
foreach (KeyValuePair<DateTime, string> keyValue in NoBot.GetCopyOfUserAddressCache())
      {
            sb.Append(keyValue.Value);
      }
      Label4.Text = sb.ToString();
}

 

Run the project

Ajax Toolkit NoBot Control in ASP.Net

In this example ResponseMinimumDelaySeconds="5"  so if you clickSubmit button before 5 second then error message will show and it will also show the IP address.

 

Ajax Toolkit NoBot Control in ASP.Net

If you click submit button after 5 second then error message will not show.

Ajax Toolkit NoBot Control in ASP.Net


Updated 22-Sep-2020

Leave Comment

Comments

Liked By