Two weeks ago, at TechEd Europe, Microsoft announced the availability of WebMatrix Beta 3. So now I want to take this opportunity to highlight some of the components WebMatrix comes with, which I think are quite interesting also for professional developers. But first, let’s start with a short introduction on WebMatrix.

WebMatrix is first of all a tool, but at the same time it contains all pieces required in order to quickly build a web site. In fact it contains a new development web server, a new web framework and an embedded database.

WebMatrix target

WebMatrix integrates all those pieces and makes it easier to get started with web development using ASP.NET. In fact one of the goals of WebMatrix is to make ASP.NET more approachable for people who are learning web development for the first time and they want to build dynamic web pages; so people who are maybe familiar with HTML, might know a little bit of CSS and want to build dynamic web pages. As a professional developer you may find WebMatrix interesting as well, for instance for quickly building your own web site or a web site for a friend; for the typical “quick&dirty” solution…you don’t have much time and you just need things done. Another target for WebMatrix are all those developers who just want to build a web site starting from an existing open source application framework, like DotNetNuke or BlogEngine.NET, all developers who just want to take one of those existing applications, customize it and deploying it without having to worry too much about the details.

As mentioned on Scott Guthrie’s blog, all WebMatrix components can be used in the full professional stack (which makes them really powerful) and it’s not a secret that all those components will be also part of a future update of Visual Studio 2010. But what are those 3 new important components which are suitable for web development?

WebMatrix components

The first one is IIS Developer Express, which is a version of IIS built specifically for development environment: you don’t have to be administrator of your machine in order to run it, no administrative privileges are required (it runs as the developer user account, no elevation required). It support all IIS 7 modules and of course ASP.NET and PHP!!! You can think at this as a replacement for the Cassini web server but with the power of IIS. Basically Microsoft took the IIS 7.5 code base that shipped with windows 7 and windows server 2008 R2 and did some changes in order to make it simpler and the right web server for a development environment: when you install it the binaries are installed in the \Programs Files folder while the configuration are installed in your profile documents folder. That’s good because it allows you to have multi-user environments (since the configurations files and the web site are being created in your profile directory every single user will have his owns websites separated from the others).

IIS Express runs as an interactive process, it doesn't run as a service. This means that it is launched when you launch WebMatrix and when you close the tool the IIS Express process will also go away.

Last, but not least, you can run it from the command-line by:

· Opening a command prompt

· Navigating to the C:\Program Files (x86)\Microsoft WebMatrix folder

· Executing iisexpress.exe /port:35896 /path:[path to your web site] à of course you can set another port number

· Opening a browser and navigating to your page: http://localhost:35896/[pageName]. html

The second component is SQL Server Compact Edition 4, which is an embedded database optimized for web applications. Visual Studio 2010 shipped with SQL Server Compact Edition 3.5 Sp2. However that database wasn’t designed for web scenario, because that database engine was not designed for the multi requests nature of web application. So with SQL Compact 4 this has been changed; SQL CE 4 has been optimized for web applications. As said SQL CE 4 is an embedded database (represented by a .SDF file); the engine itself is really small (about 2MB). It is xcopy deployable: the database engine (represented by some Dll within the \bin folder of your app) and the database itself (a .SDF file within the \App_Data folder of your app) can be copied to the server of your hosting provider and everything will just work fine. In fact no SQL Server Installation is required, which means that you don’t have to pay a SQL hosting fee in order to host your application. One great thing about SQL CE 4 is that when you develop your web app you also get full fidelity for the popular data API, including ADO.NET and Entity Framework. Another great thing is that it is compatible with SQL Server, which means that if you are using the right compatible types within your app (available on both SQL), you also get built-in migration support (from SQL CE 4 to SQL Server/Express) into the WebMatrix tool.

The last one is the new ASP.NET Web Pages Framework with Razor syntax which provides a simplified development model for building inline web pages (where you have mix between html and code, which can be C# or VB.NET). Razor it’s not a new language, it’s just a new syntax which defines how you can embed code (C# or VB.NET) into HTML. Just to be clear ASP.NET Web Pages Framework is a new framework, it has nothing to do with WebForm; we don’t have any concept of controls like we do in WebForm.

Getting Started with WebMatrix

In order to install WebMatrix the easiest way is to go to the http://www.microsoft.com/web/webmatrix . Once you are on this page you can click on the Download button. At this point the Web Platform Installer 3.0 is being downloaded (if you already have .net 4 it’s about 15 MB) and installed on your machine (if not already present), is being launched and once the following mask appears you can press on the Install button. In few minutes you will get this simple but complete development environment ready.

clip_image002[1] clip_image004[1]

Creating app from scratch or customizing existing open-source application

Once you launch WebMatrix you get the following start dialog page where you have a couple of choices:

clip_image006[1]

· My Sites: here you can see sites you have previously created.

· Site From Web Gallery: when you select this, you are connected to an online gallery of popular open-source applications like DotNetNuke or BlogEngine.NET (it’s a live feed and it will be updated on a regular basis). You can filter by category (CMS, Blogs engine, Forums and so on). Note that not only ASP.NET apps are in the gallery, but also PHP apps like WordPress, Joomla (probably the most popular ones in the PHP community). This should tell you that PHP apps work great on the Windows platform! By the way those applications are the same as the ones appearing within the Windows Web App Gallery (http://www.microsoft.com/web/gallery).

clip_image008[1]

The nice thing about WebMatrix is that it automates everything. When you select one of those applications and you press on the Next button, WebMatrix will identify the required components that need to be installed on your local development machine in order to run the selected app: it doesn’t matter if it is an ASP.NET one based on SQL Server or a PHP one based on MYSQL. All needed components will be installed for you in few minutes and everything will just run.

· Site From Template: allows you to create a new site from scratch (there are also some templates available you can start and learn from).

· Site From Folder: allows you to point to any folder on your box and start a web site from there. You open it you press F12 and you are up and running.

For a sample on how to create an application from scratch by using the new ASP.NET Web Pages Framework, or in order to get an idea of the experience you have when you choose to customize an existing open-source app, then I strongly suggest you to have a look at the following blog post from Scott Guthrie (written immediately after the launch of WebMatrix Beta1).

Once you have created your application, you probably want to publish it.

Publishing web sites

One of the things I particularly like within WebMatrix is the publishing process: when you want to go live with your created website, the process is straightforward with no pain. If you don’t have a hosting provider, WebMatrix can recommend one with the right technology for your site…just select Find Web Hosting… from the Publish menu.

clip_image010[1]

Once you have opened an account by a hosting provider, you can fill in the publishing settings dialog by selecting Settings… from the Publish menu. As you can see below you can set all fields manually with the information provided by your hoster, or another nice option you have (new in Beta3), is to press the Import Profile… button, which allows you to import a “publishing profile” from an XML file provided by your hosting provider; hosting providers can now send you a pre-configured account…in this way you don’t have to worry about the details J

Note that you can deploy your solution using Web Deploy (recommended solution), FTP of FTPs. By choosing WebDeploy, only the files that have changed are deployed (in case of an update), the server is automatically being configured, and your development machine is being synchronized with your live site (if desired).

clip_image012[1]

The next step is to validate the connection by pressing the Validate Connection button and if everything is fine you can click on the Publish button. All components which have been used within your app are being deployed on the server of your hosting provider (within the publish preview dialog you may see the SQL CE 4 engine Dlls and the ASP.NET Web Pages Framework DLLs…of course only in case you have used those components within your app).

Joining the web hosting gallery with WebMatrix support

If you are a hosting provider and you want to support WebMatrix by having your offer within the Find Web Hosting… WebMatrix’s dialog, then have a look at the following post.

Hope it helps,
Ken Casada