Ross Brooker
Ross Brooker

Reputation: 125

Google ReCaptcha - Verifying in VB .NET

I'm trying to use the new ReCaptcha code on a simple form.

The problem is getting the response at submit.

If I enter the URL by hand

https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}  

...where {0} is my secret key and {1} is the result of Request.Form("g-recaptcha-response") then it works.

If I use this code (pinched from t'net):

Dim GoogleReply = Client.DownloadString(String.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", PrivateKey, EncodedResponse))

...then it stalls with a timeout.

Is there anything wrong with the code? Or anything further I need to do to let the server side code get a response?

Upvotes: 0

Views: 2092

Answers (1)

Ross Brooker
Ross Brooker

Reputation: 125

I've used Steve's code (see above) and also found I needed to use a proxy to allow the in-code request to get through to the web.... so I've added some additional code (the extra variables area all assigned from the web.config)

                If Trim(strUseJHProxy) = "1" Then
                    Dim proxy As New System.Net.WebProxy(strJHProxyURL, False)
                    proxy.Credentials = New System.Net.NetworkCredential(strNetworkUserName, strNetworkUserPassword, strNetworkUserDomain)
                    request.Proxy = proxy
                End If

It's now working :) Thanks Steve!

Upvotes: 1

Related Questions