What is it

It’s new and it is according to Microsoft everything you need to build websites using Microsoft. Actually it contains IIS Developer Express (development web server), ASP.NET (the framework) and SQL Server Compact (SQL server embedded). It’s built to make web development with Microsoft tools available for everybody.

Install

At http://www.microsoft.com/web/webmatrix you can launch the install and automatically everything is installed on your pc.

Startup

Let’s try the webmatrix now. At start up you can choose from a few things



“Site from Web Gallery” is a collection of open-source apps (drupal, wordpress, blogengine.net,…) in different languages (php, .net,…) where you can start from. You can also choose to start from a predefined template or from an existing site on disk.

Membership application

I’ll build some small membership applications where we can manage members of our club. Let’s start with a site based on the blank template. You’ll arrive on the webmatrix dashboard from where you can manage your files, databases, hosting,…

First of all we’re going to add some files to our site. We add an index.html, members.cshtml and detail.cshtml. As you can see when you add files you can choose from different file formats. For the .NET developers, you ‘ll also find the known .aspx files. I’ve chosen to use cshtml. This is a new format using the razor view engine. It’s a new syntax built by microsoft to create views to make it easier to build pages with dynamic content. You’ll find a nice post on it on the blog of Scott Guthrie.

Database

For the demo app i’m using the SQL Compact embedded database.  You can also choose to connect to an existing datasource (SQL, MySql,…). The nice thing about Sql Compact is that the data is stored in a file and so you don’t need a database server. Thanks to this hosting your site on the web becomes very easy and cheap.

At the Dashboard choose Databases and add a new one. I create one table in it with some member related fields

Members.cshtml

With the razor syntax it is very easy to get data out of the database. In classic aspx you must write a lot more code to get the same results.

In razor every code block starts with a @. Afterwards we use a foreach to loop through the data.

And this is generating an overview page where we can see all our members

detail.cshtml

The detail screen is built to edit or add members. You can find the full code in the attached zip file. You build a form to fill in all the data and after pressing the save button you’re going to create or update a member.

Conclusion

Webmatrix is a nice new tool from Microsoft as well for experienced developers who are already used to work in Visual Studio, as for starters.

Webmatrix is ideal to build small websites, POC’s, tryout’s,… When the project is becoming more mature, you can easily  switch to Visual Studio and/or SQL Server (MySql) to build a more complex application.

Download the code here