All the examples in this document are based on .net framework.

Development environment

Item Description
Compatibility Compatible with most versions of Visual Studio, recommend to use VS 2012+
Dependency .net


Item Description
Data communication flow chart Data communication flow chart
Download SDK gt3-dotnet-sdk


Download​ ​SDK

Use​ ​command​ ​line​ ​to​ ​get​ ​from​ ​Github

git clone https://github.com/GeeTeam/gt3-dotnet-sdk.git

Download​ ​SDK​ ​manually

Get​ ​the​ ​latest​ ​SDK​ ​from Github: gt3-dotnet-sdk (in .zip format).

Import SDK

To import SDK, please firstly open the .sln file in SDK with VS.

Then, add the following code.

using GeetestSDK;

Configure key pair and modify the request

Configure key pair

Get your key pair from GeeTest Dashboard. The key pair consists of a public​ ​key(captcha ID) and a private​ ​key (KEY)​. Then, configure the key pair through the following path.


Modify the request (optional)

Variable Description
user_id User identification. If you concern about the risk of user information, you can preprocess (e.g. hashed) it.
client_type Type of client. Web (web browser for computers),h5 (mobile browser,include webview),native(native mobile app),unknown (unknow client type)
ip_address Client request for your server IP address, unknow means unknow IP address

API example

Captcha initialization

Initiate captcha via API1, get challenge and set the status

namespace demo
public partial class GetCaptcha : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
Response.ContentType = "application/json";
private String getCaptcha()
GeetestLib geetest = new GeetestLib(GeetestConfig.publicKey, GeetestConfig.privateKey);
String userID = "test";
Byte gtServerStatus = geetest.preProcess(userID,"web","");
Session[GeetestLib.gtServerStatusSessionKey] = gtServerStatus;
Session["userID"] = userID;
return geetest.getResponseStr();

Notice:status indicates captcha initialization. Status=1 refers to successful initialization, status=0 refers to downtime. Please store the status, since it will be needed in secondary verification. In the demo above, session has been used to store status.

Secondary verification (API2), including uptime and downtime

namespace demo
public partial class Validate : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
protected void submitBtn_Click(object sender, EventArgs e)
GeetestLib geetest = new GeetestLib(GeetestConfig.publicKey, GeetestConfig.privateKey);
Byte gt_server_status_code = (Byte) Session[GeetestLib.gtServerStatusSessionKey];
String userID = (String) Session["userID"];
int result = 0;
String challenge = Request.Form.Get(GeetestLib.fnGeetestChallenge);
String validate = Request.Form.Get(GeetestLib.fnGeetestValidate);
String seccode = Request.Form.Get(GeetestLib.fnGeetestSeccode);

if (gt_server_status_code == 1)
result = geetest.enhencedValidateRequest(challenge, validate, seccode, userID);
result = geetest.failbackValidateRequest(challenge, validate, seccode);
if (result == 1)
Response.Write("<div id='sb'>success</div>");
Response.Write(" ");

How to simulate the Failback mode? Please fill in an incorrect string (e.g. 123456789) for the captcha ID. Then, it will enter the Failback mode.

Run demo

To run the demo, please open the Solution Explorer and right click the demo

To view the demo, please visit​ http://localhost:2343/index.aspx in your browser.

Troubleshooting: secondary verification failure

  1. SDK internal logic errors. Please check: a) whether session is stored and read successfully, b) whether the code could successfully process to the module which send a request to GeeTest server, c) check the return value of GeeTest server.
  2. Multiple submission. The API which initiates the secondary verification is only available for one time.
  3. The challenge is inconsistent. Please ensure the consistency of challenge during the whole verification process.
  4. Check if gt and key in the code are correct in SDK. Please check if the parameters has been passed correctly.
  5. Please provide challenge to our service team. They could help you to check the log.