This is a demo of a simple contact form processing library (.NET Standard) (readme.md), deployed to NuGet.org/packages/OviCrisan.ContactForm, using Azure DevOps pipeline for CI/CD, then used in a web app + API (readme.md) (also available as Docker image at hub.docker.com/r/ovicrisan/contactformweb), Azure Function (readme.md) and AWS Lambda function (readme.md).
The core functionality of sending notification emails and/or calling a webhook or REST API using HTTP POST is provided by ContactForm .NET Standard library, then used by all other projects.
See a working example at OviCrisan.github.io/ContactForm using an Azure App Service deployment at ContactFormWeb.AzureWebsites.net. Other deployments as Azure Function, Azure Container Instance and AWS Lambda function are not currently available, but can be deployed easily, as described in the docs of those projects.
There were a few challenges with this project, like:
- Use .NET Standard 2.0 with older libraries for
Microsoft.Extensions.Logging.Abstractionsso the library can be used with AWS Lambda, which is not yet using .NET Core 3.
- Web app and API use the same endpoint ('/'), depending on the
Accept-Typeis not actually used so the rule is very simple: if passing content type
application/jsonyou will get back a JSON object response, if passing
application/x-www-form-urlencodedyou wil get back
text/htmlpossibly with a redirect status code or OK status code (200).
- Google reCAPTCHA is optional, but when used it checks version 2 with visible checkbox.