Following the example "Using reCAPTCHA with ASP.NET" but don't know how to work with SSL

221 views
Skip to first unread message

Tina

unread,
Aug 20, 2010, 12:31:08 PM8/20/10
to reCAPTCHA
Dear All,

I followed the example at here:

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

and put the Recaptcha.dll into "bin". It works prefect but not at
https page. I read some examples and said I can this script:

<script type="text/javascript"
src="https://www.google.com/recaptcha/api/challenge?
k=your_public_key">
</script>

<noscript>
<iframe src="https://www.google.com/recaptcha/api/noscript?
k=your_public_key"
height="300" width="500" frameborder="0"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
</textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript>

..... My problem is I don't know how to combine the script with the
example for VB.net.

Anybody help?!

Tina

Adrian Godong

unread,
Aug 20, 2010, 12:43:07 PM8/20/10
to reca...@googlegroups.com
1. The ASP.NET Library should work with SSL out of the box, no configuration required.

2. Put the whole script box in an ASPX page and see (the example is inline code, what you probably have is code behind).



--
You received this message because you are subscribed to the Google Groups "reCAPTCHA" group.
To post to this group, send email to reca...@googlegroups.com.
To unsubscribe from this group, send email to recaptcha+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/recaptcha?hl=en.




--
Adrian Godong
adrian...@gmail.com

Tin Chan

unread,
Aug 20, 2010, 1:04:26 PM8/20/10
to reca...@googlegroups.com
Hi Adrian,

1. The ASP.NET Library is working at https page but it shows the source of the  Recaptcha image is http but not https. So I keep getting the warning in firefox.
2. I can see the Recaptcha showing on the page but I want it work together a asp button.

Thanks

Tina

Adrian Godong

unread,
Aug 20, 2010, 1:11:44 PM8/20/10
to reca...@googlegroups.com
Paste the html or the url will help, we can't debug without looking. :D

For 1, check whether the generated HTML is calling recaptcha's HTTPS endpoint, if it doesn't then your network is configured differently than most and must use OverrideSecureMode property on the control. If it does, then it's recaptcha's fault and we can't do anything.

For 2, just move the code from inline to behind (assuming that you already have a codebehind).

Tin Chan

unread,
Aug 20, 2010, 1:34:45 PM8/20/10
to reca...@googlegroups.com
Hi Adrian,

I have done these..

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

code....

<asp:Label ID="errorCodeLabel" runat="server" Visible="false"></asp:Label>
<recaptcha:RecaptchaControl ID="recaptcha" runat="server" Theme="white" PublicKey="1234567jewfwefweweksks"
                              PrivateKey="998877665ksdjfksdf" />

<asp:ImageButton ID="createaccImageButton" runat="server" ImageUrl="/images/buttons/create_account.gif"
                    BorderWidth="0" OnClick="createaccButton_Click" /></p>

code.......

In VB:

Protected Sub createaccButton_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
    If Page.IsValid Then
         addAccountdetail()
    Else
                   
       errorCodeLabel.Text = "(Incorrect. Try again.)"
     End If

end sub

This is a https page and the recaptcha image is http so I keep getting warning message.

Thanks Adrian!

Adrian Godong

unread,
Aug 20, 2010, 1:38:38 PM8/20/10
to reca...@googlegroups.com
Have you done what I asked?

Tin Chan

unread,
Aug 21, 2010, 12:01:10 AM8/21/10
to reca...@googlegroups.com
Hi Adrian,

I have used "OverrideSecureMode" = ture and I have moved the code behid already but still the same.

Thanks

Tin Chan

unread,
Aug 21, 2010, 3:37:25 AM8/21/10
to reca...@googlegroups.com
Hi Adrian,

I have added OverrideSecureMode to here;

 <recaptcha:RecaptchaControl ID="recaptcha" runat="server" Theme="white" PublicKey="dsfh324hhkdsgfhj23g4hj"
                              PrivateKey="werwe9873248erwe" OverrideSecureMode="true"  />

But it still not working.....

Adrian Godong

unread,
Aug 21, 2010, 4:14:41 AM8/21/10
to reca...@googlegroups.com
OK, I've tested this myself using the Recaptcha.Test project (it's available on the repository).

Page is Default.aspx, set Public and Private Keys, and add OverrideSecureMode to true.

The generated HTML is:

<!-- recaptcha starts here -->
        <script type="text/javascript">
		var RecaptchaOptions = {
			theme : '',
			tabindex : 0
		};

</script><script type="text/javascript" src="https://www.google.com/recaptcha/api/challenge?k=6LeTSbwSAAAAANt5kw2yHY1Ia6Jg6osfSDo5ZMlf">

</script><noscript>
		<iframe src="https://www.google.com/recaptcha/api/noscript?k=6LeTSbwSAAAAANt5kw2yHY1Ia6Jg6osfSDo5ZMlf" width="500" height="300" frameborder="0">

		</iframe><br /><textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea><input name="recaptcha_response_field" value="manual_challenge" type="hidden" />
</noscript>
        <!-- recaptcha ends here -->
You can see all of the reference to recaptcha is being done with https protocol. This is the limit of what we can do, if these scripts suddenly returns non-https content, this is on recaptcha's side of server, and as I have said, there's no way for us to change.

Then, I switch to Web Inspector (I use Safari), and checked the Resources tab where I can see all the requests for the page. As I have suspected, all images are served via https as well.

So I can't reproduce this problem. Action items that you can do are:
1. Give us a URL that we can test, and make sure it's not working there
2. Identify which image is still using http protocol
Reply all
Reply to author
Forward
0 new messages