Inside ASP.NET Web Matrix
Alex Homer
Dave Sussman
Wrox Press Ltd.
© 2002 Wrox Press
Permission is granted to redistribute this document in its complete, original form. All other rights are reserved.
The author and publisher have made every effort during the preparation of this book to ensure accuracy of the material.
However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, Wrox
Press, nor its dealers or distributors will be held liable for any damages caused or alleged to have been caused either directly or
indirectly by this book.
Published by Wrox Press Ltd,
Arden House, 1102 Warwick Road, Acocks Green,
Birmingham, B27 6BH, UK
Trademark Acknowledgements
Wrox has endeavored to adhere to trademark conventions for all companies and products mentioned in this book, such as the
appropriate use of capitalization. Wrox cannot however guarantee the accuracy of this information.
Credits
Authors Managing Editor
Alex Homer Viv Emery
Dave Sussman
Production Coordinator &
Commissioning Editor Cover
Daniel Kent Natalie O'Donnell
Technical Editor
Daniel Richardson
About the Authors
Alex Homer is a computer geek and Web developer with a passion for ASP.NET. Although he has to spend some time doing real
work (a bit of consultancy and training, and the occasional conference session), most of his days are absorbed in playing with the
latest Microsoft Web technology and then writing about it. Living in the picturesque wilderness of the Derbyshire Dales in
England, he is well away from the demands of the real world – with only an Internet connection to maintain some distant
representation of normality. But, hey, what else could you want from life?
You can contact Alex through his own software company, Stonebroom Limited: alex@stonebroom.com.
Dave Sussman is a hacker in the traditional sense of the word. That's someone who likes playing with code and working out how
things work, which is why he spends much of his life working with beta software. Luckily this coincides with writing about new
technologies, giving him an output for his poor English and grammar. He lives in a small village in the Oxfordshire countryside.
Like many programmers everywhere he has an expensive hi-fi, a big TV and no life.
You can contact Dave through his own company, Ipona Limited: davids@ipona.co.uk.
Inside ASP.NET Web Matrix
During its relatively short but spectacularly successful life, Microsoft® Active Server Pages
(ASP) has grown from a simple scripting environment for creating dynamic Web pages into a
powerful and easy-to-use platform for fully-fledged Web application development. In its latest
incarnation, ASP.NET, it provides a complete solution for building almost any type of
interactive user interface, as well as for implementing extensive back-end processing operations.
However, despite the many powerful features of ASP, choosing a comprehensive and usable
development environment in which to create ASP applications was never easy. Many third
parties provide ASP support in their products, for example HomeSite and Macromedia
UltraDev (among others) support ASP 3.0, and, of course, Microsoft's own Visual Studio 6.0
included InterDev – which was also available as a standalone product.
With the advent of .NET, support for ASP.NET development has been fully integrated into
Visual Studio .NET. It provides an extremely powerful and usable environment for ASP.NET
development in the guise of Web Forms, as well as the more traditional types of application
(Windows Forms). And now Visual Studio .NET is joined by another Microsoft product, namely
the Microsoft ASP.NET Web Matrix Project (referred to from here on in as "Web Matrix").
At the time of writing, Web Matrix has just been released as a Beta 1 product. The whole nature
of the Microsoft ASP.NET Web Matrix project is that it will develop and grow based on
feedback from the community that uses it, so the feature set will evolve over time. You should
also keep in mind that, as this is a Beta product, there are quite a few features that are not yet
fully implemented (so some things you may expect to see are missing).
However, even at this stage Web Matrix is an extremely usable and efficient tool, and certainly
well worth installing and experimenting with. In time, it will, without doubt, mature and be
extended to provide many more of the features required for building Web sites and Web
applications using ASP.NET.
Over three sections this document will explore what Web Matrix is, what it can do, and how
you can use it:
❑ Part 1 – What is Web Matrix? provides an overview of Web Matrix, looks at the features
it provides, and the IDE it contains
❑ Part 2 – Putting Web Matrix to Work walks you through using Web Matrix to build an
application that contains many different types of pages and resources
❑ Part 3 – Configuring and Extending Web Matrix demonstrates how Web Matrix can be
configured to suit your individual requirements, and extended by installing your own or
third-party add-ins
Part 1 – What is Web Matrix?
From first impressions, you may think that Web Matrix is just a simplified development
environment for building ASP.NET applications. In fact, it provides much more than this. As
well as ASP.NET pages (including mobile device pages), Web Matrix can be used to create user
controls and class files (for compiling into assemblies), Web service files, and even HTTP
Handlers. It also provides integrated support for creating and editing HTML pages, style sheets,
XML schemas and documents, text files and SQL scripts, and .NET configuration files (such as
web.config and global.asax).
Web Matrix also provides powerful wizards that automate much of the process of creating pages
that handle data, pages that use output caching, and pages that use the built-in ASP.NET
authentication features. It also comes complete with its own web server, and other useful add-
ins. You can even create and install your own add-ins if you wish.
Why Use Web Matrix Instead of Visual Studio .NET?
Before we look in detail at Web Matrix, it's worth exploring the differences between it and
Visual Studio .NET. After all, why should Microsoft provide two different development
environments for ASP.NET? The answer is that they complement each other – they target
different types of development.
Visual Studio .NET is an excellent team development environment, which – when integrated
with a source file control system such as Visual SourceSafe – provides for the safe and
consistent management of project files when a team of people are working on a project.
One big difference between Web Matrix and Visual Studio .NET is that the latter insists on
creating ASP.NET projects using the code-behind technique, rather than inline code. Many
traditional ASP developers are used to including the presentation content (such as HTML, text,
etc.) in the same file as the ASP code that creates and manages the dynamic interface content.
Whether this is a good idea depends on how you (and your team) actually develop applications.
If you employ graphical designers to build the visual parts of pages, and then employ other,
more technically oriented programmers to build the code, you may prefer to have separate files
for these two sections of the interface.
However, you might prefer to include both code and visual content in the same inline page,
perhaps to avoid the added complexity of having to compile the code-behind file and then
inherit from it in the visual interface page (even though Visual Studio .NET does this for you).
Developing in this way, until Web Matrix appeared, meant going back to the pre-ASP.NET
approach of using a simple text editor (such as Notepad) or some other third-party tool.
In summary, the differences between Web Matrix and Visual Studio .NET are:
❑ Project-based Solutions – Visual Studio .NET has the concept of a project, to which you
can add various types of file and resource. Web Matrix does not use a project-based
approach; instead it treats each file as a separate item.
❑ ASP.NET Page Structure – Web Matrix creates ASP.NET pages using the inline
approach, rather than the code-behind approach of Visual Studio .NET.