Building ASP.NET Web Pages with Microsoft WebMatrix
Copyright 2011 by Steve Lydford
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher.
ISBN-13 (pbk): 978-1-4302-4020-4
ISBN-13 (electronic): 978-1-4302-4021-1
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
President and Publisher: Paul Manning
Lead Editor: Ewan Buckingham
Technical Reviewer: Andy Olsen
Editorial Board: Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Morgan Ertel,
Jonathan Gennick, Jonathan Hassell, Robert Hutchinson, Michelle Lowman, James Markham,
Matthew Moodie, Jeff Olson, Jeffrey Pepper, Douglas Pundick, Ben Renow-Clarke, Dominic
Shakeshaft, Gwenan Spearing, Matt Wade, Tom Welsh
Coordinating Editor: Adam Heath
Copy Editor: Chandra Clarke
Compositor: Apress Production (Christine Ricketts)
Indexer: SPI Global
Artist: SPI Global
Cover Designer: Anna Ishchenko
Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail .
For information on translations, please e-mail .
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk SaleseBook Licensing web page at www.apress.com/bulk-sales
.
The information in this book is distributed on an as is basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work.
Any source code or other supplementary materials referenced by the author in this text is available to readers at www.apress.com
. For detailed information about how to locate your books source code, go to http://www.apress.com/source-code/
.
To my wonderful wife Wendy (WWW) for her love and unending support,
and our four amazing kids Tomos, Wiliam, Amy, and Isabel who make us both so very proud.
Steve Lydford
Contents at a Glance
Contents
About the Author
Steve Lydford had been a professional software developer since 1999, although he first learnt to program computers at the age of seven, when his father brought home a Sinclair Spectrum with a black and white portable television and a massive 16Kb of RAM! The countless hours spent typing in listings from Sinclair User magazine sparked an enthusiasm for programming that has stayed with him for life.
During his career, Steve has worked for a variety of small companies, web startups, and corporations, developing systems on an assortment ofmostly web-basedplatforms. Currently, he develops almost exclusively on the ASP.NET platform and has worked on many successful projects using Web Forms, MVC, and WebMatrix, which he has followed with great interest since its initial beta release. He enjoys writing and speaking to fellow developers, particularly about emerging web technologies.
Steve lives with his family in mid-Wales where he loves to walk in the mountains and spends far too much time in front of a computer, usually working on his next big idea.
About the Technical Reviewer
Andy is a freelance consultant/developer/instructor based in the UK. Andy has been working with .NET since Beta 1 days and has worked on numerous book projects with Apress over the last tenyears. Andy lives by the seaside in Swansea with his family, and enjoys running (with mandatory coffee stops en route), skiing (of a fashion), and watching the Swans!
Acknowledgments
Huge thanks to all the team at Apress who have guided me through this, my first book. Thanks to Ewan Buckingham for getting the whole thing going and working with me to produce the initial table of contents. Thanks also to Adam Heath for guiding the project to its successful conclusion and answering my countless emails and questions on the whole publishing processmost of which is still largely a mystery to me! And massive thanks to the Technical Reviewer, Andy Olsen, who did an outstanding job, meticulously checking all the code and technical details. The excellent feedback he provided has greatly enhanced the final copy.
Most importantly, I would like to thank my beautiful wife Wendy and our four great kids Tomos, Wiliam, Amy, and Isabel. Without their love and support this book would never have seen the light of day. Ill take next weekend off, I promise!
Steve
Introduction
Microsoft WebMatrix is a free web development tool that includes everything required to create small and medium-sized web applications. The tool includes a web server, a powerful server-side scripting language, and a database, all of which can be used from within its own customized, lightweight development environment. From the outset, it has been designed to provide developers with an easy-to-learn, easy-to-use, rapid web development platform.
By the end of this book, you will have learned all the skills necessary to develop dynamic, data-driven web sites using the tools provided as part of the WebMatrix platform. We will cover every part of the toolset in detail and see how each can be best used to provide real-world solutions to common web development tasks. Later in the book (in ), we will use the skills learned to develop a fully-functional e-commerce web site, which includes a data-driven product catalog, membership system, shopping cart, and checkout process as well as site administration pages and other features.
In the text, I have assumed that the reader has no prior knowledge of WebMatrix, or the other Microsoft ASP.NET web development platforms. In order to follow the examples in the book you will simply need a working knowledge of HTML and Cascading Style Sheets (CSS); however, readers with previous experience of another framework, such as PHP or Rails, will certainly find this beneficial. For readers with little previous programming experience, I have, wherever possible, provided links and references to online information and books to help you broaden your knowledge.
Code Samples
Sample code from the book is available for download from the Apress web site. To obtain the files, visit www.apress.com
and search for the book. Once you have found it you can download the files from the Source Code/Downloads tab.
The sample files are compressed into a single ZIP file, which contains folders for each of the chapters for which source code is available.