在C#ASP.NET中重温v3

在C#ASP.NET中重温v3,c#,asp.net,.net,recaptcha-v3,C#,Asp.net,.net,Recaptcha V3,我正在尝试让Google reCAPTCHA v3在ASP.NET网络表单上工作。我使用的库是bitaromy.ReCaptcha(),但示例代码无法编译: //1. Get the client IP address in your chosen web framework string clientIp = this.HttpContext.Connection.RemoteIpAddress.ToString(); string token = null; string secret =

我正在尝试让Google reCAPTCHA v3在ASP.NET网络表单上工作。我使用的库是bitaromy.ReCaptcha(),但示例代码无法编译:

//1. Get the client IP address in your chosen web framework
string clientIp = this.HttpContext.Connection.RemoteIpAddress.ToString();
string token = null;
string secret = "your_secret_key";

//2. Extract the `#captcha` field from the hidden HTML form in your chosen 
web framework
if( this.Request.Form.TryGetValue("captcha", out var formField) )
{
    token = formField;
} 

//3. Validate the reCAPTCHA with Google
var captchaApi = new ReCaptchaService();
var result = await captchaApi.Verify3Async(token, clientIp, secret);

if( !result.IsSuccess || result.Action != "SOME_ACTION" || result.Score < 0.5 )
{
    // The POST is not valid
    return new BadRequestResult();
}
else{
    //continue processing, everything is okay!
}
//1。获取所选web框架中的客户端IP地址
string clientIp=this.HttpContext.Connection.RemoteIpAddress.ToString();
字符串标记=null;
string secret=“您的密钥”;
//2. 从所选文档中隐藏的HTML表单中提取`#captcha`字段
web框架
if(this.Request.Form.TryGetValue(“验证码”,out var formField))
{
token=formField;
} 
//3. 使用Google验证reCAPTCHA
var captchaApi=新的RecaptChasService();
var结果=等待captchaApi.Verify3Async(令牌、客户端、机密);
如果(!result.issucess | | | result.Action!=“某些| | |操作”| result.Score<0.5)
{
//该帖子无效
返回新的BadRequestResult();
}
否则{
//继续处理,一切正常!
}
我在this.HttpContext.Connection.RemoteIpAddress、this.Request.Form.TryGetValue和result.IsSuccess(result.*等)上收到错误。该站点正在运行.NET4.8。这在.NETFramework上有效吗?还是只在.NETCore上有效

谢谢