简体   繁体   English

如何在单页应用程序 (SPA) 中实现 ReCaptcha

[英]How do I implement ReCaptcha in a Single Page Application (SPA)

I have a Single Page Application (SPA) I would like to add ReCaptcha to.我有一个单页应用程序 (SPA),我想向其中添加 ReCaptcha。 This application is hosted using IIS as flat Html, Css & Javascript, this SPA in turn talks to a separate REST server (using CORS) for all dynamic content.此应用程序使用 IIS 作为平面 Html、Css 和 Javascript 托管,此 SPA 又与单独的 REST 服务器(使用 CORS)对话以获取所有动态内容。

The REST server is written using ASP.net WebAPI. REST 服务器是使用 ASP.net WebAPI 编写的。 The problem is;问题是; all examples I have seen of ReCaptcha all use ASP.net MVC (or other languages) to inject html into the webpage, I cannot modify the webpage using ASP.net in this manor.我见过的所有ReCaptcha的例子都是使用ASP.net MVC(或其他语言)将html注入到网页中,我无法在这个庄园使用ASP.net修改网页。 Hopefully someone else has had the same problem.希望其他人也遇到过同样的问题。

I am really looking for some 2 parts, first the HTML that belongs on the client, and secondly the Controller that would be on the REST Server to verify with google.我真的在寻找一些 2 部分,首先是属于客户端的 HTML,其次是将在 REST 服务器上与谷歌验证的控制器。 Even if this is in another language that I can convert, this will be useful!即使这是我可以转换的另一种语言,这也会很有用!

看起来我想要的只是使用没有插件的 reCaptcha ( https://developers.google.com/recaptcha/docs/display )

I have used ngx-captcha with my angular project.我在我的 angular 项目中使用了 ngx-captcha。 Here's how I kept my submit button disabled until recaptcha checkbox is checked.这是我如何禁用提交按钮,直到选中 recaptcha 复选框。

 //code <ngx-recaptcha2 (success)="handleSuccess($event)" #captchaElem [siteKey]="siteKey" formControlName="recaptcha"> </ngx-recaptcha2>

once captcha is filled , it emits a success event , so use it in a method to make a variable true/false based on which you can enable/disable submit button一旦验证码被填充,它就会发出一个成功事件,所以在一个方法中使用它来创建一个变量真/假,你可以根据它启用/禁用提交按钮

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使单页应用程序 (SPA) 可从 SharePoint 搜索? - How do you make a single-page-application (SPA) searchable from SharePoint? 如何部署React JS单页应用程序(SPA) - How to deploy react js single page application (SPA) 如何强制更新单页应用程序(SPA)页面? - How to force update Single Page Application (SPA) pages? 如何在单页应用程序 (SPA) 中正确配置 Firebase 身份验证? - How to properly configure Firebase Auth in a single page application (SPA)? 为单页应用程序(SPA)编译HTML片段? - compiling HTML fragments for Single Page Application (SPA)? 加快单页应用程序(SPA)中的渲染 - Speed up rendering in Single Page Application (SPA) 如何使用骨干,jquery,需要js获取单个页面应用程序(SPA)的页面加载时间? - How to get page load time for a single page application(SPA) using backbone,jquery, require js? 如果在 SPA(单页应用程序)中被其他页面加载中断,如何避免以前的 ajax 响应? - How to avoid previous ajax response if interrupted by other page load in SPA(Single Page Application)? 如何使用 Puppeteer 在 SPA 中检索新页面内容? - How Do I Retrieve New Page Content in an SPA using Puppeteer? 如何使用导航栏创建单页面应用程序? - How do I create single page application using a navbar?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM