In a recent series of posts I described how the new WebMatrix suite of Web components from Microsoft fit in with DotNetNuke (DNN).  But what are WebPages and Razor – and how do we (ASP.NET developers) use them to build Web Applications. 

In this series of articles I will dive deeper into these new technologies.  We will start at the very beginning – Creating your first Website using WebMatrix.

Create Your First WebMatrix Website

I will assume that WebMatrix is installed – if not, you can refer to one of my earlier posts to see how to go about downloading and installing it from the Web Application Gallery.

To create your first Website using WebMatrix, launch WebMatrix and select “Site From Template” from the splash screen.

WebMatrix_01

You will then be presented with a page which provides a number of different site templates (the list of templates included may vary – this list is from the WebMatrix Beta 2).  Choose the “Empty Site” template – and call the site “Hello World”.

WebMatrix_02

You will then be presented with the following view in Web Matrix of your new empty site.

WebMatrix_03

Of course as the site has no content you cannot browse to it yet, so we will create a page in our site, by selecting the Files option (highlighted), which shows the files in our site.

WebMatrix_04

As we created an “Empty Site”, not surprisingly there are no files, so select the New option (highlighted), or click the “Add a file to your site” link in WebMatrix’s content pane.  You will then be presented with a “Gallery” of new file types which can be created.

WebMatrix_05

By default the “CSHTML” file type is selected – accept that option and call the new Web Page “HelloWorld.cshtml”.

WebMatrix_06

That’s it – you have created your new “ASP.NET WebPage” based Website.  I added the HTML in between the body tags, so we can actually see something when we browse to the page.  You can view the page in your browser by clicking on the Run button.  WebMatrix allows you to run the page in a single browser – or you can view the page in all of the browsers installed on your system.

WebMatrix_07

You must make sure that the page you wish to view in the browser is the selected page in the site -   WebMatrix will always attempt to load the select page.

WebMatrix_08

Note that the url in the Browser is "http://localhost:29263/HelloWorld.cshtml”.  This is because we are using IISExpress as our webserver, one of the components that is included in the WebMatrix product suite.

While this article demonstrated how to create a site – the site is not very interesting yet as it just contains static content, and you could have done that with a plain old HTML page. 

The CSHTML file type is a new type of file as it allows you to mix markup (HTML) with code C#.  For those of you who prefer Visual Basic as your language there is also a VBHTML file type which allows you to use Visual Basic for the code part.

In the next article in this series, I will introduce the Razor parser and Razor syntax, and we will create our first Razor WebPage.


Posted in: WebMatrix , ASP.NET  Tags: ,

 Search Blog

 Calendar

«  May 2012  »
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910
View posts in large calendar

 Tags

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2012 Thoughts from the Wet Coast