我试图让新的Google reCaptcha在我的ASP.NET项目中工作,我遇到了问题,让它成为新的"我不是机器人".
我在那里有旧的,在对developers.google.com网站进行了大量研究后,一切看起来都一样(他们甚至指向我下载相同的dll - 1.0.5).所以,我得到了新的密钥并将它们放入并且它可以工作,但它看起来就像旧的reCaptcha.
有没有人得到新的ASP.Net工作?我错过了什么?
编辑:
因此,在测试应用程序中搜索并搜索其他一些网站,我发现如果我创建这样的页面:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>reCAPTCHA demo: Simple page</title>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
</head>
<body>
<form id="form1" runat="server" action="?" method="POST">
<div>
<div class="g-recaptcha" data-sitekey="My Public Key"></div>
<br/>
<asp:Button ID="Button1" runat="server" Text="Submit" />
</div>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
然后在我的代码隐藏(Button1_Click)中,我这样做:
Dim Success As Boolean
Dim recaptchaResponse As String = request.Form("g-recaptcha-response")
If Not String.IsNullOrEmpty(recaptchaResponse) Then
Success = True
Else
Success = False
End If
Run Code Online (Sandbox Code Playgroud)
该recaptchaResponse
要么是空的或填充取决于他们是否是僵尸或没有.问题是,我现在需要把这个回复用私钥发送给google,这样我就可以验证响应是不是由机器人提供的,在我的代码隐藏中,但我无法弄清楚如何.我试过这个(取代Success = True
):
Dim client As New …
Run Code Online (Sandbox Code Playgroud) 实际通话:
ChildClass classCall=new ChildClass();
classCall.FullName="test name";
string returnName=classCall.GetName();
Run Code Online (Sandbox Code Playgroud)
使用方法的父类:
public class BaseClass
{
public string GetName()
{
// I can request the value of the property like this.
return this.GetType().GetProperty("FullName")
.GetValue(this, null).ToString();
}
}
Run Code Online (Sandbox Code Playgroud)
儿童班:
public partial class ChildClass : BaseClass
{
public string FullName;
public int Marks;
}
Run Code Online (Sandbox Code Playgroud)
问题:如何避免硬编码属性名称,即GetProperty("FullName")
.我不想硬编码属性名称,而是使用其他方法并在父方法中使用它?