Google Recaptcha and EPiServer.Forms

Forms 3.0.0, CMS 9.12, MVC

Last night I played with EPiServer Forms. And there is a sample pack to install as Eric Herlitz blogs about, for the moment containing a calender picker and Googles Recaptcha, real neet!

Install the EPiServer.Forms.Samples: http://www.herlitz.nu/2016/08/30/add-the-missing-date-time-field-in-episerver-forms/

The RecaptchaElementBlock as it is, needs to have specified a sitekey and secret key (Register at https://www.google.com/recaptcha/ to get your keys)

I found it unfortunate that the editors needed to fill in and remember the keys every time, so i found out a way to set them automaticly when the element block is created thanks to Alf Nilssons sample code on github. (by the way setting Allow Anonymous on Forms is a prefered default)

https://github.com/alfnilsson/EpiserverForms/blob/master/Toders.Forms.Web/Business/Forms/AllowAnonymousSubmissionDefault.cs

My code:

 

Disabling EPiServer Scheduled Jobs programmatically in non production environment

Scenario: You just have copied the Production Database to your development server or to the testservers but you don’t want that some important jobs to be activated and running in the background on a non production environment.

Solution: Automatically disable EPiServer Scheduled Jobs programmatically in the initualization.

Following Māris Krivtežs blog post which describes greatly how to work with scheduled jobs. http://marisks.net/2015/05/04/episerver-working-with-scheduled-jobs-programmatically/

My code:

How to determind production server or not:

Explanation: If you are using Config Transforms and any automatic deployment system, in my case Octopus, the “Environment” appsettings is set in the transform config. eg

A second possibility is to check the MachineName.

More about scheduled jobs: http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-CMS/8/Scheduled-jobs/Scheduled-jobs/