I have a Single Page Application (SPA) I would like to add ReCaptcha to.
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.
The REST server is written using 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. 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. Even if this is in another language that I can convert, this will be useful!
Looks like what I wanted was simply to use reCaptcha without plugins (https://developers.google.com/recaptcha/docs/display)
I have used ngx-captcha with my angular project.
Here's how I kept my submit button disabled until recaptcha checkbox is checked.
//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
Related
I have an lotus domino form that will be filled by the user of my web app. You can see it on the image below.
As you know, those fields that use the client-side code will be filled automatically when the form is loaded and when the agent in web query save triggered. How do i recreate this "mechanism" when i'm using SSJS code to create this form?
FYI, i'm creating an API using SSJS to create this form. So the data that i'll receive from the front-end are those that filled by user. It'll be too much work if i have to code the fields that supposed to be filled by client-side code. And the front-end that i'm using is Angular.
Pardon my english.
On a XPages there is the possibility to trigger and Query Save action, see http://www.xpageswiki.com/apps/wiki-xpages/wiki-xpages.nsf/page.xsp?documentId=C483F4FA895B5790C12578090038E377&action=openDocument#Set+fields+in+backend+document+in+QuerySave+event
I am reading a website project created on VS 2010 vb.net, where they have implemented a webservice.asmx in the same project to be called in javascript methods. In other words: the webservice is not implemented as API, it is a webservice.asmx where I can add methods to call database, and those methods are used in javascript functions.My questions are:
What is the importance of calling a webservice from javascript instead of making a postback to the server and retrieve data form there?
What about sessions? Does the webservice can view sessions of the user? I am asking this question because I can view some sessions filled as: HttpContext.Current.Session("UserID") = userId.
If it is possible to catch and fill sessions of the user pages, is it possible to have access to controls in asp pages of the same user? And Why?
I am a little bit confused with this webservice, what I know is that webservice runs on a server and is used as API in applications... this is the first time that I work with a webservice and website written in the same project, thank you.
1
Calling a WebService is a lot quicker than doing a PostBack, so if you want to only do partial updates of your website, a WebService is a good option to use (if you'd create the project from scratch, you'd use a Web API instead of an ASMX WebService). Of course, you have to integrate the result into the Web page on the client side. If you want to have asynchronous requests that lead to changes in the UI, you could also use an UpdatePanel on the ASPX-page.
It is also common to host the WebService in the same application as the Web frontend to avoid CORS issues.
2
The WebService can also access the session of the user if you set EnableSession on the WebMethod attribute to true. See this question for some pitfalls.
3
As the request to the WebService is a separate request it does not have direct access to a page's controls on the server (read in C#/VB.NET code), but you can change the HTML document tree on the client by using JavaScript.
If you need to share code on the server between the pages and the WebService, you should create separate methods in a helper/business logic class that are called by both the pages and the WebService.
To give an example, if both a page and the WebService need to get data from the database, you'd move the code for the database access from the ASPX page into a separate class (which is a good idea for many other reasons) and use the class both in the ASPX page and the WebService.
I have the requirement to try out with converting an existing page in the project to use angularjs/bootstrap. Please correct me if I am wrong in my approach.
My project uses asp webforms, where I am planning to change one aspx page(which has grids, radiotbuttons and other asp controls as well ) to use angularjs controls .
What I have understood so far is that we need to have webmethods in the serverside which provide the data for the controls. So what all controls now declared in the serverside is not needed and I need to have the respective html controls in the client side and clientside angularjs calls the webmethod and returns the serialized data to controls in client side.I won't be able to access the server side controls in the webmethod as webmethods are static .
So in short we need to move all the logics that are in the existing aspx.vb for the controls to the client side angularjs code and only thing we can make use of with the aspx.vb is to provide the webmethods to provide data for the controls in client side.
Can someone correct me please ?
All your controls will need to be built using HTML and not ASP.Net controls.
You are correct in saying you will need to bind your HTML controls to the data you have sent back from the server. With regards to the logic of your form, that can sit in an angular service that your angular controller calls.
This will allow your logic to be encapsulated and be called from any angular controller.
You may use WCF, ASP.Net Web API or any server side technology that will allow http requests to provide/modify your data.
Moving a page at a time from ASP(X) to angular is probably a lot of effort. You would first want to start exposing your business logic via WCF/Web Api first and then move your application to use Angular.
The issue:
I have written a ton of code (to automate some pretty laborious tasks online), and have used the mechanize library for Python to handle network requests. It is working very well, except now I have encountered a page which I need javascript functionality... mechanize does not handle javascript.
Proposed Solution:
I am using PyQt to write the GUI for this app, and it comes packaged with QtWebKit, which DOES handle javascript. I want to use QtWebKit to evaluate the javascript on the page that I am stuck on, and the easiest way of doing this would be to transfer my web session from mechanize over to QtWebKit.
I DO NOT want to use PhantomJS, Selenium, or QtWebKit for the entirety of my web requests; I 100% want to keep mechanize for this purpose. I'm wondering how I might be able to transfer my logged in session from mechanize to QtWebKit.
Would this work?
Transfer all cookies from mechanize to QtWebView
Transfer the values of all state variables (like _VIEWSTATE, etc.) from mechanize to QWebView (the page is an ASP.net page...)
Change the User-Agent header of QWebView to be identical to mechanize...
I don't really see how I could make the two "browsers" appear more identical to the server... would this work? Thanks!
Since nobody answered, I will post my work-around.
Basically, wanted to "transfer" my session from Mechanize (the python module) to the QtWebKits QWebView (PyQt4 module) because the vast majority of my project was automated headless, but I had encountered a road block where I had no choice but to have the user manually enter data into a possible resulting page (as the form was different each time depending on circumstances).
Instead of transferring sessions, I met this requirement by utilizing QWebViews javascript functionality. My method went like this:
Load page in Mechanize, and save the downloaded HTML to a local temporary file.
Load this local file in QWebView.
The user can now enter required data into the local copy of this page.
Locate the form fields on this page, and pull the data the user entered using javascript. You can do this by getting the main frame object for the page (QWebView->Page()->MainFrame()), and then evaluating javascript code to accomplish the above task (use evaluateJavaScript()).
Take the data you have extracted from the form fields, and use it to submit the form with the connection you still have open with mechanize.
That's it! A bit of a work-around, but it works none-the-less :\
I have a very simple issue and I'm looking for a simple way to do that.
In fact, I'm searching to auto-fill a Web-Form from an official webPage of an institution and I would like to do it in Javascript into a webpage which will do it automatically on client-side.
I tried CasperJS/PhantomJS which is very useful to do that but they have to be run by command line and not by a js script.
This webForm is very simple.It has several dropdownList, checkboxes and text input with a simple submit button.
I don't need some detailed code but just the way/tools to achieve that. I'm on it since 2 weeks without any good results.
Ideally, this should be done server to server. What you want is a web service. This way you don't have to have a client machine with a browser sitting open to handle this.
A quicker and dirtier method would be to submit the form data directly to the 3rd party web server via cURL:
https://superuser.com/questions/149329/what-is-the-curl-command-line-syntax-to-do-a-post-request
http://curl.haxx.se/docs/httpscripting.html
The best way to do that is using Selenium. Use Selenium and you can easily fill out forms of third party.