zoukankan      html  css  js  c++  java
  • 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

查看全文
  • 相关阅读:
    C++ 值传递、指针传递、引用传递
    typedef与#define的区别
    const与#define的区别
    头文件重复引用
    多态
    ng双向数据绑定
    angular响应式编程
    angular的一些问题
    npm install 权限的问题
    typescript的入门
  • 原文地址:https://www.cnblogs.com/zxhoo/p/1947395.html
  • Copyright © 2011-2022 走看看