CYAN
MAGENTA
YELLOW
BLACK
PANTONE 123 CV
BOOKS FOR PROFESSIONALS BY PROFESSIONALS ®
Pro ASP.NET 2.0 E-Commerce
in C# 2005
Author of
Beginning Visual Web
Developer 2005 Express:
From Novice to Professional
Co-Author
ASP to ASP.NET Migration
Handbook: Concepts and
Strategies for Successful
Migration
Throughout my many years of developing e-commerce applications, I have
encountered countless problems and solutions that I have always wanted to
share with my fellow developers. This book is the product of those experiences.
Pro ASP.NET 2.0 E-Commerce in C# 2005 discusses all the decisions you
have to make when designing and developing an ASP.NET 2.0 e-commerce
application for a client, from gathering the requirements to deploying the
application. Because e-commerce is often a vague concept, it can be hard at
first to pin down exactly what is involved in a successful solution. To overcome
this problem, I have created a fictitious company, Little Italy Vineyards, that I use
as a case study throughout this book. Using this real-world approach, I show
you how to turn e-commerce concepts into code.
After you have read this book and followed the case study from beginning to
end, you will have a solid understanding of how to develop a professional
ASP.NET 2.0 e-commerce application that is scalable and secure. Specifically,
you will learn about the finer points of application architecture, about how to
set up your Visual Studio 2005 project correctly, and about how to obtain and
install the SSL certificates you will need. I cover the software engineering
decisions extensively, as you might expect, but I also cover all the business
elements you need to know to develop and maintain a successful e-commerce
application that will fulfill your client’s expectations.
Thank you for reading; I wish you every success in your development efforts.
Paul Sarknas
RELATED TITLES
Companion eBook
See last page for details
on $10 eBook version
Companion eBook
Available
Pro
ASP.NET 2.0 E-Commerce
Dear Reader,
THE EXPERT’S VOICE ® IN .NET
Pro
ASP.NET 2.0
E-Commerce
in
C# 2005
Learn the secrets behind a successful ASP.NET 2.0 e-commerce solution.
in C#
2005
SOURCE CODE ONLINE
www.apress.com
ISBN 1-59059-724-9
www.littleitalyvineyards.com
55999
US $59.99
Paul Sarknas
Sarknas
Shelve in
Microsoft/.NET
User level:
Intermediate–Advanced
6
89253 59724
8
9 781590 597248
this print for content only—size & color not accurate
spine = 1.205" 640 page count
7249ch00FM.qxd
11/13/06
9:14 PM
Page i
Pro ASP.NET 2.0
E-Commerce in
C# 2005
Paul Sarknas
7249ch00FM.qxd
11/13/06
9:14 PM
Page ii
Pro ASP.NET 2.0 E-Commerce in C# 2005
Copyright © 2006 by Paul Sarknas
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-59059-724-8
ISBN-10 (pbk): 1-59059-724-9
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence
of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark
owner, with no intention of infringement of the trademark.
Lead Editor: Ewan Buckingham
Technical Reviewer: Fabio Claudio Ferracchiati
Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Jason Gilmore, Jonathan Gennick,
Jonathan Hassell, James Huddleston, Chris Mills, Matthew Moodie, Dominic Shakeshaft, Jim Sumser,
Keir Thomas, Matt Wade
Project Manager: Kylie Johnston
Copy Edit Manager: Nicole Flores
Copy Editor: Kim Wimpsett
Assistant Production Director: Kari Brooks-Copony
Production Editor: Kelly Winquist
Compositor/Artist: Kinetic Publishing Services, LLC
Proofreader: Lori Bring
Indexer: Brenda Miller
Cover Designer: Kurt Krames
Manufacturing Director: Tom Debolski
Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor,
New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail , or
visit .
For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA
94710. Phone 510-549-5930, fax 510-549-5939, e-mail , or visit .
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.
The source code for this book is available to readers at in the Source Code/Download
section.
7249ch00FM.qxd
11/13/06
9:14 PM
Page iii
Contents at a Glance
About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
PART 1
■■■
■CHAPTER 1
■CHAPTER 2
■CHAPTER 3
PART 2
PART 3
■CHAPTER
■CHAPTER
■CHAPTER
■CHAPTER
■CHAPTER
■CHAPTER
The Project Plan and Design
Modeling Objects with UML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Designing the Database with SQL Server 2005 . . . . . . . . . . . . . . . . . 55
Using Visual Studio 2005 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
■■■
10
11
12
13
14
15
The Business Aspects
Gathering the Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Turning Sales into Profits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Examining the Risks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
■■■
■CHAPTER 7
■CHAPTER 8
■CHAPTER 9
PART 4
Introducing E-commerce Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Introducing the Microsoft Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Exploring the Company Background for the Case Study . . . . . . . . . 13
■■■
■CHAPTER 4
■CHAPTER 5
■CHAPTER 6
The Basics
Architecture
Building the Complete System Architecture . . . . . . . . . . . . . . . . . . . . 111
Creating the Common Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Creating the Data Access Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Creating the Business Logic Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Exploring Your Integration Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Creating the Presentation Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
iii
7249ch00FM.qxd
11/13/06
PART 5
■CHAPTER
■CHAPTER
■CHAPTER
■CHAPTER
■CHAPTER
■CHAPTER
■CHAPTER
PART 6
9:14 PM
■■■
16
17
18
19
20
21
22
Page iv
Core Development
Developing the Product Catalog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
Building the Shopping Cart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
Integrating the PayPal SDK. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
Implementing the Checkout Process . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Processing the Payment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
Creating the Administrator’s Control Panel. . . . . . . . . . . . . . . . . . . . . 433
Building the Customer’s Account . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
■■■
Order Fulfillment and Promotion
■CHAPTER 23 Managing the Orders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501
■CHAPTER 24 Promoting the Site and Upselling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
■CHAPTER 25 Accessing the Money from the Credit Card Transaction . . . . . . . . 567
PART 7
■■■
Deployment
■CHAPTER 26 Exploring Your Compilation and Deployment Options . . . . . . . . . . . 575
■CHAPTER 27 Configuring the Production Environment. . . . . . . . . . . . . . . . . . . . . . . 583
PART 8
■■■
Aftercare
■CHAPTER 28 Supporting and Maintaining the Application . . . . . . . . . . . . . . . . . . . 601
■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609
iv
7249chIDX.qxd
616
11/13/06
9:29 PM
Page 616
■INDEX
solution file, creating, 92
source code. See code; exercises
SQL caching invalidation, 604
SQL injection attacks, 34
SQL Server 2005, 8, 55–89
SQL Server 2005 Express, 56
SQL Server jobs, deleting abandoned
shopping carts and, 314
SQL Server Management Studio, 55
SQLHelper class, 165
SSL (Secure Sockets Layer) certificates, 8, 33,
590–596
Starkowicz, Eric, 191
State field, 75
stored procedures, 34, 224–228
StoredProcedure class, 142, 165, 274
SubmissionError property, 389, 422
SubmitOrder() method, 422
subscriptions, 24
supply and demand, 31
support, 601–607
symbols, for activity diagrams, 40
system architecture, 111–114
business logic layer and, 151
data access layer and, 131
system boundaries, 47
system downtime, 32
■T
T-SQL (Transact-SQL), 8
Table Script
Address table, 76
ContactInformation table, 77
EndUser table, 73
EndUserType table, 74
OrderDetails table, 70
Orders table, 68
OrderStatus table, 71
Product Category table, 65
ProductImages table, 66
ShoppingCart table, 79
tables, 59–79, 87
Tax property, 496
test certificates
configuring, 342
creating, 336
incorporating into web projects, 344
textShippedDate text box, 523
tiers, 111
tilde (~), 495
tools, 7–11
ASPNET_REGSQL, 605
Class Designer, 8
.NET Framework 2.0, 8
SQL Server Management Studio, 55
traffic-monitoring, 601
Visio, 8
Visual Studio 2005. See Visual Studio 2005
tracking orders, 23
TrackingNumber field, 68
traffic, monitoring, 601
Transact-SQL (T-SQL), 8
TransactionBase class, 427
TransactionID field, 67
transactions. See processing payments
try/catch statements, 190
type inserts, 87
TypeName field, 74
■U
UI (user interface), design/layout for, 191
UML (Unified Modeling Language), 8, 39–54
uniform resource locator (URL), specifying
for PayPal, 580
UnsubscribeCustomer() method, 566
updating
orders, 518–524
products, 457–468
shopping cart, 300–313
upselling, 28, 533–543
URL (uniform resource locator), specifying
for PayPal, 580
use cases, 46
user accounts, creating, 350–365, 475–498
user interface (UI), design/layout for, 191
UserData property, 555
users. See customers
Utilities class, 180
■V
Visio (Microsoft), 8, 39
Visual Studio 2005 (Microsoft), 7, 91–108
business logic layer, implementing into,
154
7249chIDX.qxd
11/13/06
9:29 PM
Page 617
■INDEX
Default.aspx web form and, 199
refactoring within, 126–130
Visual Studio 2005 Class Designer tool, 8
VPN connections, 597
■W
warnings, resolving, 575
web forms, creating, 198–220
web pages
creating, 198–220
master page and, 192–198
Web project, 95, 99
web references, adding to projects, 181
web servers, IIS and, 585
617
web services, 181–187
Web.config file, finalizing, 597
WebLog Expert tool, 601
website. See e-commerce application
wine business case study. See Little Italy
Vineyards case study
Wine of the Month Club, 24, 29
Winery web page, 202
■X
XML data, 113
■Z
ZIP code, 75
Find it faster at />