Creating the simplest possible ASP.NET Core form with a POST method

.NET Core, .NET Standard, ASP.NET, Razor
See comments

Simple HTML form in ASP.NET Core

Recently I needed to create a simple page for someone to submit an HTML form. The rest of the Azure aplication is running on Azure serverless functions, Logic apps and Cognitive services, but for that last part I wanted something where the user can click on a link, open the page in a web browser (probably on a mobile device), enter a passphrase in a form and then submit through a POST to an SSL encrypted page. I thought of writing a small Xamarin app and submitting through POST to an Azure Function. Another option would be to use a static HTML page and to use Javascript to submit the Form through a POST to that Azure Function. I don't exclude these two options for the future.

But in the meantime I wanted to experiment with a simple Razor page (CSHTML) that would present an HTML Form to the user, and submit this Form to itself with a POST over HTTPS.

I noticed that the documentation is not great about how to do this in the simplest possible manner and so I created an example with source code and complete instructions.

I hope this is helpful to you!

Happy coding

Laurent

Previous entry

Comments for Creating the simplest possible ASP.NET Core form with a POST method