creating an umbraco form using pure razor

CREATING AN UMBRACO FORM USING PURE RAZOR
OVERVIEW
Traditionally forms have always been created in Umbraco 4 via a Web Forms user-control.
Usually these will use standard ASP.NET server controls and validators. However, this type
of form can exhibit a number of problems:




It will require you to create your content within a single server side form tag
with runat="server". This can be restrictive when you have multiple forms you
want to handle.
ASP.NET validator controls aren't very configurable and don't provide the rich
feedback people now expect from forms.
The framework inject all sorts of JavaScript and ViewState into your nice, clean
semantic mark-up.
Your form won't be easily testable.
So in this package I'm going to show you how to create a simple form using pure Razor and
C# - with no web-forms, ViewState or ASP.NET controls in site! The aim of this is to
demonstrate some useful techniques that help fulfill the following criteria:







Our form must use both server-side and client-side validation.
It should utilise strongly-typed models to help prevent typo errors and provide full
intellisense.
It mustn’t place any restrictions on mark-up or layout.
It should not require any dependency on ASP.NET web-forms (so no runat="server"
required).
It should use a simple, unobtrusive "honey pot" method to deter spam bots.
It should prevent accidental re-submission of the form if the page is reloaded.
Our "business logic" should be separated from our presentation layer (as far as is
possible) and be testable.
For more information on this please read my blog-post at:
http://www.diplo.co.uk/blog/2012/5/24/creating-an-umbraco-form-using-pure-razor.aspx
INSTALLATION
When you install the package it should install the following files:



A master page template called DiploRazorForm.master
A CSHTML Razor script called DiploRazorForm.cshtml
Two C# files in /App_Code/ called Diplo.ContactFormModel.cs & Diplo.Repository.cs
Just try out the form just create a page using the Diplo Razor Form template. This contains all the resources
and the macro.