• reCAPTCHA验证码控件for ASP.NET


    from http://code.google.com/apis/recaptcha/docs/aspnet.html

    The reCAPTCHA ASP.NET Library provides a simple way to place a CAPTCHA on your ASP.NET website, helping you stop bots from abusing it. The library wraps the reCAPTCHA API. You can use the library from any .NET language including C# and Visual Basic .NET.

    To use reCAPTCHA with ASP.NET, you can download the reCAPTCHA ASP.NET library.

    Quick Start

    After you've signed up for your API keys, below are basic instructions for installing reCAPTCHA on your site with ASP.NET:

    1. Add a reference on your website to library/bin/Release/Recaptcha.dll: On the Visual Studio Website menu, choose Add Reference and then click the .NET tab in the dialog box. Select the Recaptcha.dll component from the list of .NET components and then click OK. If you don't see the component, click the Browse tab and look for the assembly file on your hard drive.
    2. Insert the reCAPTCHA control into the form you wish to protect by adding the following code snippets:

      At the top of the aspx page, insert this:

        <%@ Register TagPrefix="recaptcha" Namespace="Recaptcha" Assembly="Recaptcha" %>

      Then insert the reCAPTCHA control inside of the <form runat="server"> tag:

        <recaptcha:RecaptchaControl
          ID="recaptcha"
          runat="server"
          PublicKey="your_public_key"
          PrivateKey="your_private_key"
          />

      You will need to substitute your public and private key into PublicKey and PrivateKey respectively.

    3. Make sure you use ASP.NET validation to validate your form (you should check Page.IsValid on submission).

    The following is a "Hello World" with reCAPTCHA using Visual Basic. A C# sample is included with the library download.

      <%@ Page Language="VB" %>
      <%@ Register TagPrefix="recaptcha" Namespace="Recaptcha" Assembly="Recaptcha" %>
      <script runat=server%gt;
          Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs)
              If Page.IsValid Then
                  lblResult.Text = "You Got It!"
                  lblResult.ForeColor = Drawing.Color.Green
              Else
                  lblResult.Text = "Incorrect"
                  lblResult.ForeColor = Drawing.Color.Red
              End If
          End Sub
      </script>
      <html>
      <body>
          <form runat="server">
              <asp:Label Visible=false ID="lblResult" runat="server" />
              <recaptcha:RecaptchaControl
                  ID="recaptcha"
                  runat="server"
                  Theme="red"
                  PublicKey="your_public_key"
                  PrivateKey="your_private_key"
                  />

              <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
          </form>
      </body>
      </html>
    Further Reading
  • Customizing Look and Feel
  • Tips and Guidelines

reCAPTCHA首页:http://www.google.com/recaptcha

recaptcha.dll下载地址:http://code.google.com/p/recaptcha/downloads/list?q=label:aspnetlib-Latest

申请reCAPTCHA key地址:https://www.google.com/recaptcha/admin/create

转自:http://www.cnblogs.com/mathewxiang/archive/2010/08/26/1808910.html

  • 相关阅读:
    图,深度,广度优先遍历(一)
    java实现快速排序
    图,深度,广度优先遍历(二)
    图,深度,广度优先遍历(三)
    Jpa动态多表if多条件联合查询(if中包含list不为null和“=”的判断),并对查询结果进行分页
    SpringBoo启动报错:Failed to load property source from location ‘classpath:/bootstrap.yml‘
    Java对象创建和Javabean创建
    Linux解压命令
    BDD测试利器:mocha+should.js
    《老码识途》读书笔记:第一章(中)
  • 原文地址:https://www.cnblogs.com/zxhoo/p/1947395.html
  • Copyright © 2020-2023  润新知