Microsoft WebMatrix and Razor
Written by Ian Elliot   
Thursday, 08 July 2010

Microsoft WebMatrix is a new way to get started with a website and it introduces the new Razor view engine syntax to the complete beginner. Has Microsoft found a way to get its web technology accepted by all?

Banner

 

Microsoft has a problem with its current offering of web development tools - there are too many of them! It can be difficult to figure out how to get started and what to use to do what. Now we have WebMatrix the latest attempt to make it all so simple that one download solves everything. It also makes use of the Razor view engine which simplifies the construction of ASP .NET pages by introducing a new syntax for inline code.

 

matrix

The new WebMatrix site, which is still in beta, has the headline:

Everything you need to build Web sites using Windows.

Small, simple and seamless.

I'm not 100% sure what "small, simple and seamless" is supposed to mean but I sort of get the idea.

In practice what you are being offered is a bundle of free software based on the Web Platform Installer.  If you have already got .NET 4.0 installed then the download is just 15MB. Included in the package is IIS Developer Express - see the news report IIS Express - beta nearly ready - ASP .NET and SQL Server Compact a new embedded version of SQL server.  WebMatrix itself is a small utility that sets up and configures a range of web sites including, surprisingly a set of PHP based sites. Once you have everything setup you can opt to open the site in either Visual Studio 2010 or the free Web Developer 2010. Notice that WebMatrix doesn't replace the familiar development tools -but it does contain a code and database editor to get you started. In most cases however you are likely to have to move to a full IDE to create anything complex.

WebMatrix is essentially about getting you started with a Microsoft based web site. It is about setting up, profiling and deployment. It even includes a section that helps you find a company to host your site. It will deploy your site automatically and even upgrade to full IIS and SQL server for you.

A second important feature of WebMatrix is that it encourages the use of the new Razor view engine syntax for inline code. The current version doesn't support the Razor view engine in full MVC applications as yet, but you can use it to create standalone ASP .NET pages. A full version of Razor for MVC applications will be released later and will integrate with Visual Studio.

The basic idea is to allow a new way to create ASP pages by quoting code inline within HTML. 

The intention is that a simplified syntax will help the beginner mix HTML and C' or VB .NET code to create dynamic pages. For example a traditional ASP .NET inline code block might be something like:

<ul>
<% foreach(var pin products){ %>
 <li> <% = p.Name %> ($ <% = p.Price %>) </li>
 <% } %>
</ul>

Using the Razor view engine this could be written as:

<ul>
@foreach(var p in products){
 <li> @p.Name ($ @p.Price )</li>
}
</ul>

The basic idea is to use @ to indicate the start of inline code but notice that no closing indicator is required - the view engine works out where the code ends and HTML starts from the syntax. The code block continues for as long as the syntax is valid code.

This is possibly a good idea as it does simplify the look of the dynamic page but ducks the question of whether or not inline code is a good idea at all. It also encourages the beginner to think of inline code as some sort of macro language for text generation. This is a problem that has to be solved with all languages that generate or manipulate HTML on the server - see Object-oriented HTML generation.

 

matrix

In many ways WebMatrix, and Razor in particular, represent another splintering of the Microsoft web technology stack. They do succeed in making things simple but exactly what they make simple is the real question and does it lead on to something bigger and better?

 

Banner


Pico 2W Announced But There Is A Surprise!
25/11/2024

Raspberry Pi released the Pico 2 a few months ago and we have been waiting for the Pico 2W since then. But Pimoroni beat them to the draw with the Pico Plus 2W based on the RM2 radio module and hinted [ ... ]



Copilot Improves Code Quality
27/11/2024

Findings from GitHub show that code authored with Copilot has increased functionality and improved readability, is of better quality, and receives higher approval rates than code authored without it.

 [ ... ]


More News

<ASIN:0735627401>

<ASIN:1430225114>

<ASIN:0672333058>

<ASIN:1430225297>

<ASIN:0470505451>

<ASIN:1430228865>

<ASIN:0470643188>

Last Updated ( Thursday, 08 July 2010 )