Load Captcha Site Key from Data Base

Viewed 156

I need to get the Site Key from the DB.(instead of setting it directly on the project or web.config)

How can I load the JavaScript api and perform a POST request with my sitekey from the DB?

<script src="http://www.google.com/recaptcha/api.js?render=SITE_KEY"></script>

.....

grecaptcha.ready(function () {
                grecaptcha.execute('SITE_KEY', { action: 'homepage' }).then(function (token) {
                    $.ajax({
                        type: "POST",

Best I've been able is to get values from web.config with:

<script src="http://www.google.com/recaptcha/api.js?render=<%#RecaptchaSiteKey%>"></script>

grecaptcha.execute('<%#RecaptchaSiteKey%>', { action: 'homepage' }).then(function (token) {

In .cs

public string RecaptchaSiteKey = ConfigurationManager.AppSettings["GoogleReCaptchav3SiteKey"].ToString();
0 Answers
Related