Chapter 1
Getting Started with WebMatrix
What you will learn in this chapter:
- What WebMatrix is all about
- How to acquire and install WebMatrix
- How to create a simple site with WebMatrix
- Where to go within WebMatrix to get things done
- What file types you are likely to be working with
- How to structure a website
In the early days of web development on the Windows platform in the 90s of the last decade Microsoft offered a relatively simple and approachable technology, now referred to as Classic ASP, which enabled inexperienced web developers and even non-programmers to build simple websites. Getting started with Classic ASP was easy; all you needed was a text editor and a hosting account to run your site. With the release of ASP.NET and Visual Studio .NET in early 2002, the web development landscape changed considerably. Although extremely powerful, ASP.NET is not easily approachable, and certainly not so for non-programmers. It has a pretty steep learning curve and requires experience in programming. The tool used to build ASP.NET websites Visual Studio is also a lot more complex to use than a simple text editor. In addition, it takes a fair bit of time to download and install Visual Studio.
Although the advent of ASP.NET and Visual Studio addressed the needs of experienced and professional programmers and was generally seen as a major leap forward, Microsoft no longer had a good option for people starting out with web development. To accommodate this group of users and make it easier for them to start developing websites on the Windows platform, Microsoft developed WebMatrix that was first released in January 2011. In this book, youll get an in-depth look at WebMatrix and how to use it, starting with instructions on acquiring and installing WebMatrix in this chapter, all the way down to deploying a fully functional website to a production environment in Chapter 14.
In the next section youll learn what WebMatrix is and how to install it. The section that follows introduces you to ASP.NET Web Pages the development framework youll be using in WebMatrix. The second half of this chapter then gives you an extensive tour of the WebMatrix user interface.
Introducing WebMatrix
In this introductory section youll learn what WebMatrix is and why you should use it. In addition, youll learn how to acquire and install it, setting you up for the many exercises youll find throughout this book.
What Is WebMatrix?
Many people tend to refer to WebMatrix as the lightweight tool to create web pages using the new Web Pages Framework and Razor syntax. However, WebMatrix is more than just the tool. WebMatrix is a stack of software components required to build web applications delivered seamlessly in one package. There are four core components to the stack: a web server (IIS Express); a development framework (.NET 4.0); a database platform (SQL Server Compact Edition 4.0); and a lightweight web authoring and management tool.
IIS Express is a lightweight web server used to serve up pages and other requests made by the browser. It offers all of the core features of the full version of IIS 7, the web server that is typically used in production hosting scenarios on server editions of Windows. It doesnt require administrator privileges to run, nor does it require complex configuration. It can run on any operating system from Windows XP upwards (including Home Edition).
The .NET Framework is a huge collection of code libraries, which offer pre-built solutions to many, many common programming problems. The framework also includes a common language infrastructure, which enables developers to pick from many languages to write their applications in. The most popular languages are C# and VB. ASP.NET is a web development framework that sits on top of the .NET Framework.
SQL Server Compact Edition (SQL CE) is a file-based database system, which you use to store your data in. Since it is file-based, SQL CE does not require you to run a setup program or install and configure a database server in order to use it. Databases are stored as files on disk with an SDF extension (similar to an Access database), and are easily copied to a web server or other machine via FTP, X-Copy, or similar. The database engine runs in memory within the application and shuts down automatically when it is no longer needed. It has a relatively slim set of features compared to the full version of SQL Server, which makes it very easy to work with.
The WebMatrix UI provides a host of tools for creating websites from templates or from scratch, downloading pre-built Open Source applications and customizing them, managing files, databases, publishing your web application to a web server, testing and configuring your site, optimizing your site for search engines, and more.
Why Should You Use WebMatrix?
There is a wide choice of programming languages and frameworks available to those who are just beginning web development, including PHP, Ruby on Rails, Java, ColdFusion, and even classic ASP so why choose WebMatrix?
WebMatrix provides a relatively simple approach to web development, which can help you become productive very quickly. But dont let the simplicity of the development tool fool you. Behind the scenes you have access to the full power of the .NET Framework. The .NET Framework is composed literally of thousands of libraries of pre-written code covering nearly every programming requirement you will ever need. Microsoft is constantly expanding the framework, and of course fully supports it. Furthermore, a huge and active community of volunteers actively supports ASP.NET at places such as Wroxs own forums ( http://p2p.wrox.com/ ) and the official Microsoft ASP.NET forums ( http://forums.asp.net ), where the authors of this book actively participate and try to answer your questions.
When planning WebMatrix, the development team at Microsoft decided that simplicity is key, and everything they do is driven by a desire to keep the concept count low for beginners to web development. There is stuff that every developer of dynamic websites needs to know, regardless of the framework they choose: HTML, CSS, some JavaScript, SQL, and server-side code. To varying degrees, all frameworks obscure some of the unnecessary details relating to these fundamentals. In doing so, some frameworks introduce a new range of concepts to learn and become familiar with. The upside of this is that once the new concepts are learned, you can enjoy a consistent development experience that encourages RAD, or Rapid Application Development. The downside is that learning the new concepts can take a long time and might overwhelm the beginner.
WebMatrix goes back to the roots of web development. It encourages you to immerse yourself in HTML, CSS, JavaScript, and more, which are accessible technologies common to all web development platforms. It also includes a range of helpers, which are wrappers around some of the common tasks you will perform when developing a website, such as data access, managing security, and sending e-mail. These helpers provide shortcuts more than anything, and they are very easy to learn and use. You typically access these helpers from your web pages using either Visual Basic or C# code. The examples in this book all use C# as the language of choice, but you could follow along with Visual Basic if you prefer.
Another great feature of WebMatrix is its price: Its completely free. This means you can follow along with all the examples from this book, and build great production-ready websites without spending a dime.
How Do You Acquire WebMatrix?
In theory, its possible to create ASP.NET Web Pages applications using any text-editing package, such as Notepad. In theory, its also possible for you to commute to work or college on your hands and knees. I wouldnt recommend either as a sensible option. Get a bus or train, drive a car, or cycle to work or college, and use WebMatrix for Web Pages development.