MVC 3 RC VS 2010 Template w/ Razor, Html 5 Boilerplate and OpenId AuthenticationAug 25 2010
### Updated 3/21/2011:
Now with twitter and oauth support. See [the latest update](http://www.michaelhamrah.com/blog/2011/03/updated-mvc3-html5-boilerplate-template-now-with-twitter-and-facebook/)
I’ve created an (arguably) bare-minimum Visual Studio 2010 Template for getting started with MVC 3 Preview 1 using the Razor view engine and some other web goodies. I got tired of the vanilla “Welcome to MVC” homepage and I’m not a fan of the MembershipProvider abstraction and all the Account junk included by default. This template is meant to provide a bare-bones setup of Html 5 and provide OpenId authentication for users (but not full-on user management)- it’s a simple cocktail of Html5 Boilerplate and DotNetOpenAuth. The rest is left up to you to build up!
Paul Irish’s Html5 Boilerplate
Paul Irish created a nice starting point for Html5 websites with his Html5 Boilerplate. There’s a lot of goodies in it which go beyond just changing the DOCTYPE. Check out the NetTuts+ official guide to Html5 Boilerplate explained by Paul himself. I’ve ported over the .9 version with comments so you can see what’s what. The only changes made where to replace the url’s in script and link tags with @Url.Content methods. The original index page is at the root (you’ll want to delete, but it’s a handy reference) and the _Layout.cshtml now has a Header and Script section to use in child pages. This functionality is used in the LogOn view to set up OpenId authentication.
OpenId with DotNetOpenAuth
I was never a fan of the stock MembershipProvider infrastructure and setup of the sql tables required for user management. Usually, user management requires very specific needs site to site, and the default functionality gets butchered anyway. So all that stuff gets pulled and replaced with the ease and simplicity of OpenId. The template uses the OpenId Selector on the login page and DotNetOpenAuth with Forms Authentication on the backend. There’s no Register page, as the specifics of the required user schema varies too much. But you should be able to combine the OpenId logic on the Login page with a new Register page to suit your needs. There’s also no persistence store integrated into the template as that is left entirely up to you.
I really have no set goals for this template, so it will evolve in a free form manner. The code is on GitHub so feel free to branch and edit as necessary. I’m going to add some unit tests around the OpenId logic, and possibly evolve the Account creation in some way. So that’s about it!