Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将recaptcha v3令牌分配给变量?_C#_Asp.net_Model View Controller_Recaptcha_Html.dropdownlistfor - Fatal编程技术网

C# 如何将recaptcha v3令牌分配给变量?

C# 如何将recaptcha v3令牌分配给变量?,c#,asp.net,model-view-controller,recaptcha,html.dropdownlistfor,C#,Asp.net,Model View Controller,Recaptcha,Html.dropdownlistfor,我想将我的recaptcha v3令牌分配给一个变量。我想以一种形式使用这个变量,我不能从recaptcha脚本中获取值。在我的recaptcha脚本中,我希望获取令牌值并将其分配给变量,正如代码中所示。我在dropdownlist中使用mystringtoken变量。我怎样才能从剧本中得到它?问候 @{ string mystringtoken = "";} <script src="https://www.google.com/recaptcha/api.

我想将我的recaptcha v3令牌分配给一个变量。我想以一种形式使用这个变量,我不能从recaptcha脚本中获取值。在我的recaptcha脚本中,我希望获取令牌值并将其分配给变量,正如代码中所示。我在dropdownlist中使用mystringtoken变量。我怎样才能从剧本中得到它?问候

@{ string mystringtoken = "";}
<script src="https://www.google.com/recaptcha/api.js?render=mysitekey
"></script>
<script>grecaptcha.ready(function () {
        grecaptcha.execute('mysitekey', { action: 'submit' }).then(function (token) {

            var elements = document.querySelectorAll('.token');
            elements.forEach(function (element) {
                element.value = token;
                @mystringtoken=element.value


            });


        });

    });</script>```


@{string mystringtoken=”“;}
grecaptcha.ready(函数(){
执行('mysitekey',{action:'submit'})。然后(函数(令牌){
var elements=document.querySelectorAll('.token');
elements.forEach(函数(元素){
element.value=令牌;
@mystringtoken=element.value
});
});
});```

@mystringtoken
根据定义无法工作,因为它是服务器端,而JS是客户端。