Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
1001binary committed Apr 1, 2015
1 parent a3a23c3 commit 2d67828
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ In order to use for asp.net mvc, you need to install more a helper package. This

``` Install-Package GoogleRecaptchaMvc ```

In order to use for asp.net web forms, you need to install more a package. This package is used to create the server control for Google Recaptcha:

``` Install-Package GoogleRecaptchaWebForms ```

### Samples
#### ASP.NET MVC
We will have a minor sample for asp.net mvc. In this sample, we have a view called __Index.cshtml__ and a controller named __HomeController__. In __index__ view, we will render the html control with the Google reCaptcha version 2 format. Also, HomeController will have 2 actions inside it. The first action is to implement the GET request. The second action is to implement the POST request used to verify the Google Recaptcha. The following is the sample code:

__Index.cshtml__:
Expand Down Expand Up @@ -57,6 +62,37 @@ public class HomeController: Controller
}
```

#### ASP.NET Web Forms
For asp.net web forms, after you have installed the library, you have two ways to use it:
* Refer to it in web.config:
```xml
...
<system.web>

<pages>
<controls>
<add tagPrefix="asp" assembly="GoogleRecaptchaWebForms"/>
</controls>
</pages>

</system.web>
...
```
* Refer to it in each pages aspx or user controls ascx:
```xml
<%@ Register TagPrefix="asp" Namespace="GoogleRecaptchaWebForms" Assembly="GoogleRecaptchaWebForms" %>
```

Next you can use server control of Google Recaptcha for any page or user control:
```xml
...
<asp:RecaptchaV2Control ID="gRecaptcha" SiteKey="[YOUR_SITE_KEY]"
SecretKey="[YOUR_SECRET_KEY]" runat="server"/>
...
```

Finally on the server-side, you can verify the captcha by using __Page.IsValid__ or __gRecaptcha.IsValid__. The success is __true__, otherwise is __false__

### Bugs and Issues
If any issue or bug, please push a new issue [here](https://github.com/congdongdotnet/GoogleRecaptcha/issues).

Expand All @@ -65,6 +101,7 @@ If any issue or bug, please push a new issue [here](https://github.com/congdongd
* 1.0.1: Add the meaningful comments into code and fix some following performance bugs:
* Dispose and close the unnecessary resources when using MemoryStream.
* Use the HtmlHelper class in the namespace System.Web.Mvc instead of System.Web.WebPages.Html.
* 1.1.1: Support the Google Recaptcha version 2 for asp.net web forms.

### Copyright and License
Copyright 2015 by CongDongDotNet - MIT License

0 comments on commit 2d67828

Please sign in to comment.