Tải bản đầy đủ (.pdf) (1,731 trang)

Wrox professional ASP dot NET 3 5 in c sharp and VB mar 2008 ISBN 0470187573 pdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (38.93 MB, 1,731 trang )


Evjen

Professional

ASP.NET 3.5
In C# and VB
Bill Evjen
Scott Hanselman
Devin Rader

Wiley Publishing, Inc.

ffirs.tex V2 - 01/28/2008

4:55pm

Page iii


Evjen ffirs.tex

V2 - 01/28/2008

4:55pm

Page ii


Evjen


ffirs.tex V2 - 01/28/2008

4:55pm

Professional

ASP.NET 3.5
In C# and VB
Chapter 1: Application and Page Frameworks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 2: ASP.NET Server Controls and Client-Side Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Chapter 3: ASP.NET Web Server Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Chapter 4: Validation Server Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
Chapter 5: Working with Master Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
Chapter 6: Themes and Skins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
Chapter 7: Data Binding in ASP.NET 3.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Chapter 8: Data Management with ADO.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
Chapter 9: Querying with LINQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
Chapter 10: Working with XML and LINQ to XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497
Chapter 11: IIS7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557
Chapter 12: Introduction to the Provider Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587
Chapter 13: Extending the Provider Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627
Chapter 14: Site Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661
Chapter 15: Personalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723
Chapter 16: Membership and Role Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 757
Chapter 17: Portal Frameworks and Web Parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 811
Chapter 18: HTML and CSS Design with ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 861
Chapter 19: ASP.NET AJAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 895
Chapter 20: ASP.NET AJAX Control Toolkit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 929
Chapter 21: Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 995
Chapter 22: State Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1033

Chapter 23: Caching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1071
Chapter 24: Debugging and Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1103
Chapter 25: File I/O and Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1139
Chapter 26: User and Server Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1193
Chapter 27: Modules and Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1275
Chapter 28: Using Business Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1297
Chapter 29: Building and Consuming Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1325
Chapter 30: Localization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1381
Chapter 31: Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1409
Chapter 32: Instrumentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1461
Chapter 33: Administration and Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1499
Chapter 34: Packaging and Deploying ASP.NET Applications . . . . . . . . . . . . . . . . . . . . . . . . . 1529
Appendix A: Migrating Older ASP.NET Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1567
Appendix B: ASP.NET Ultimate Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1583
Appendix C: Silverlight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1607
Appendix D: ASP.NET Online Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1627

Index

1629

Page i


Evjen ffirs.tex

V2 - 01/28/2008

4:55pm


Page ii


Evjen

Professional

ASP.NET 3.5
In C# and VB
Bill Evjen
Scott Hanselman
Devin Rader

Wiley Publishing, Inc.

ffirs.tex V2 - 01/28/2008

4:55pm

Page iii


Evjen ffirs.tex

V2 - 01/28/2008

Professional ASP.NET 3.5
In C# and VB
Published by
Wiley Publishing, Inc.

10475 Crosspoint Boulevard
Indianapolis, IN 46256

www.wiley.com
Copyright © 2008 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-18757-9
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
Library of Congress Cataloging-in-Publication Data is available from the publisher.
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any
means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections
107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or
authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood
Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be
addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317)
572-3447, fax (317) 572-4355, or online at />Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties
with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties,
including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended
by sales or promotional materials. The advice and strategies contained herein may not be suitable for every
situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting,
or other professional services. If professional assistance is required, the services of a competent professional person
should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an
organization or Website is referred to in this work as a citation and/or a potential source of further information
does not mean that the author or the publisher endorses the information the organization or Website may provide
or recommendations it may make. Further, readers should be aware that Internet Websites listed in this work may
have changed or disappeared between when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the
United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress

are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and
other countries, and may not be used without written permission. All other trademarks are the property of their
respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be
available in electronic books.

4:55pm

Page iv


Evjen

fauth.tex V1 - 02/20/2008

1:50am

About the Authors
Bill Evjen is an active proponent of .NET technologies and community-based learning initiatives for
.NET. He has been actively involved with .NET since the first bits were released in 2000. In the same year,
Bill founded the St. Louis .NET User Group (www.stlnet.org), one of the world’s first such groups. Bill
is also the founder and former executive director of the International .NET Association (www.ineta.org),
which represents more than 500,000 members worldwide.
Based in St. Louis, Missouri, USA, Bill is an acclaimed author and speaker on ASP.NET and XML
Web Services. He has authored or co-authored more than fifteen books including Professional C# 2008,
Professional VB 2008, ASP.NET Professional Secrets, XML Web Services for ASP.NET, and Web Services
Enhancements: Understanding the WSE for Enterprise Applications (all published by Wiley Publishing, Inc.).
In addition to writing, Bill is a speaker at numerous conferences, including DevConnections, VSLive, and
TechEd. Along with these items, Bill works closely with Microsoft as a Microsoft Regional Director and
an MVP.

Bill is the Technical Architect for Lipper (www.lipperweb.com), a wholly-owned subsidiary of Reuters, the
international news and financial services company. He graduated from Western Washington University
in Bellingham, Washington, with a Russian language degree. When he isn’t tinkering on the computer, he
can usually be found at his summer house in Toivakka, Finland. You can reach Bill at
Scott Hanselman works for Microsoft as a Senior Program Manager in the Developer Division, aiming to spread the good word about developing software, most often on the Microsoft stack. Before
this he worked in eFinance for 6+ years and before that he was a Principal Consultant at a Microsoft
Partner for nearly 7 years. He was also involved in a few things like the MVP and RD programs and
will speak about computers (and other passions) whenever someone will listen to him. He blogs at
and podcasts at and contributes to
, , and .
Devin Rader is a Product Manager on the Infragistics Web Client team, responsible for leading the
creation of Infragistics ASP.NET and Silverlight products. Devin is also an active proponent and member of the .NET developer community, being a co-founder of the St. Louis .NET User Group, an active
member of the New Jersey .NET User Group, a former board member of the International .NET Association (INETA), and a regular speaker at user groups. He is also a contributing author on the Wrox title
Silverlight 1.0 and a technical editor for several other Wrox publications and has written columns for
ASP.NET Pro magazine, as well as .NET technology articles for MSDN Online. You can find more of
Devin’s musings at www.geekswithblogs.com/devin.

Page v


Evjen

fauth.tex V1 - 01/28/2008

4:58pm

Page vi


Evjen


fcredit.tex V1 - 01/28/2008

4:59pm

Credits
Acquisitions Director

Editorial Manager

Jim Minatel

Mary Beth Wakefield

Development Editors

Production Manager

Adaobi Obi Tulton
Sydney Jones

Tim Tate

Vice President and Executive Group Publisher
Technical Editors
Eric Engler
Alexei Gorkov
Doug Holland
Darren Kindberg
Mark Strawmeyr


Richard Swadley

Vice President and Executive Publisher
Joseph B. Wikert

Project Coordinator, Cover
Lynsey Stanford

Production Editor
Angela Smith

Proofreader
Sossity Smith

Copy Editors
Nancy Rapoport
Sydney Jones

Indexer
J & J Indexing

Page vii


Evjen

fack.tex

V1 - 01/28/2008


Acknowledgments
I have said it before, and I will say it again: Writing a book may seem like the greatest of solo endeavors,
but it requires a large team of people working together to get technical books out the door-and this
book is no exception. First and foremost, I would like to thank Jim Minatel of Wrox for giving me the
opportunity to write the original ASP.NET book, which then led to this special edition. There is nothing
better than getting the opportunity to write about your favorite topic for the world’s best publisher!
Besides Jim, I worked with the book’s development editor, Adaobi Obi Tulton. Adaobi kept the book
moving along even with all the interruptions coming our way. Without Adaobi’s efforts, this book would
not have happened.
I worked closely with both Scott Hanselman and Devin Rader on this book, and these guys deserve a lot
of thanks. I appreciate your help and advice throughout the process. Thanks guys!
I would also like to thank the various editors who worked on this book: Alexei Gorkov, Mark Strawmeyr,
Darren Kindberg, Eric Engler, and Doug Holland. Big and ongoing thanks go to the Wrox/Wiley gang
including Joe Wikert (publisher), Katie Mohr (acquisitions editor), and David Mayhew (marketing).
Finally, thanks to my entire family. Book writing is a devil in disguise as it is something that I love to do
but at the same time, takes way too much time away from my family. Thanks to my family for putting
up with this and for helping me get these books out the door. I love you all.
— Bill Evjen

4:59pm

Page viii


Evjen

ftoc.tex V2 - 01/28/2008

5:00pm


Contents
Introduction

xxxi

Chapter 1: Application and Page Frameworks

1

Application Location Options

1

Built-In Web Server
IIS
FTP
Web Site Requiring FrontPage Extensions

The ASP.NET Page Structure Options
Inline Coding
Code-Behind Model

ASP.NET 3.5 Page Directives
@Page
@Master
@Control
@Import
@Implements
@Register

@Assembly
@PreviousPageType
@MasterType
@OutputCache
@Reference

2
3
4
5

6
8
10

13
14
17
18
19
21
21
22
22
23
23
24

ASP.NET Page Events
Dealing with PostBacks

Cross-Page Posting
ASP.NET Application Folders

24
26
27
33

\App_Code Folder
\App_Data Folder
\App_Themes Folder
\App_GlobalResources Folder
\App_LocalResources
\App_WebReferences
\App_Browsers

33
38
38
39
39
39
39

Page ix


Evjen

ftoc.tex V2 - 01/28/2008


Contents
Compilation
Build Providers
Using the Built-in Build Providers
Using Your Own Build Providers

40
44
45
46

Global.asax
Working with Classes Through VS2008
Summary

51
54
61

Chapter 2: ASP.NET Server Controls and Client-Side Scripts

63

ASP.NET Server Controls

63

Types of Server Controls
Building with Server Controls

Working with Server Control Events

64
65
67

Applying Styles to Server Controls

70

Examining the Controls’ Common Properties
Changing Styles Using Cascading Style Sheets

HTML Server Controls
Looking at the HtmlControl Base Class
Looking at the HtmlContainerControl Class
Looking at All the HTML Classes
Using the HtmlGenericControl Class

Manipulating Pages and Server Controls with JavaScript
Using Page.ClientScript.RegisterClientScriptBlock
Using Page.ClientScript.RegisterStartupScript
Using Page.ClientScript.RegisterClientScriptInclude

Client-Side Callback
Comparing a Typical Postback to a Callback
Using the Callback Feature — A Simple Approach
Using the Callback Feature with a Single Parameter
Using the Callback Feature — A More Complex Example


70
72

76
79
80
80
81

83
84
86
88

89
89
90
96
99

Summary

105

Chapter 3: ASP.NET Web Server Controls

107

An Overview of Web Server Controls
The Label Server Control

The Literal Server Control
The TextBox Server Control

107
108
110
111

Using the Focus() Method
Using AutoPostBack
Using AutoCompleteType

x

112
113
114

5:00pm

Page x


Evjen

ftoc.tex V2 - 01/28/2008

5:00pm

Contents

The Button Server Control
The CausesValidation Property
The CommandName Property
Buttons That Work with Client-Side JavaScript

The LinkButton Server Control
The ImageButton Server Control
The HyperLink Server Control
The DropDownList Server Control
Visually Removing Items from a Collection
The ListBox Server Control
Allowing Users to Select Multiple Items
An Example of Using the ListBox Control
Adding Items to a Collection

The CheckBox Server Control
How to Determine Whether Check Boxes Are Checked
Assigning a Value to a Check Box
Aligning Text Around the Check Box

The CheckBoxList Server Control
The RadioButton Server Control
The RadioButtonList Server Control
Image Server Control
Table Server Control
The Calendar Server Control
Making a Date Selection from the Calendar Control
Choosing a Date Format to Output from the Calendar
Making Day, Week, or Month Selections
Working with Date Ranges

Modifying the Style and Behavior of Your Calendar

AdRotator Server Control
The Xml Server Control
Panel Server Control
The PlaceHolder Server Control
BulletedList Server Control
HiddenField Server Control
FileUpload Server Control
Uploading Files Using the FileUpload Control
Giving ASP.NET Proper Permissions to Upload Files
Understanding File Size Limitations
Uploading Multiple Files from the Same Page
Placing the Uploaded File into a Stream Object
Moving File Contents from a Stream Object to a Byte Array

115
115
115
117

119
119
120
121
124
125
126
126
129


129
131
131
131

132
134
136
138
139
142
142
144
144
144
147

151
153
153
156
157
162
164
164
167
167
170
172

173

xi

Page xi


Evjen

ftoc.tex V2 - 01/28/2008

Contents
MultiView and View Server Controls
Wizard Server Control
Customizing the Side Navigation
Examining the AllowReturn Attribute
Working with the StepType Attribute
Adding a Header to the Wizard Control
Working with the Wizard’s Navigation System
Utilizing Wizard Control Events
Using the Wizard Control to Show Form Elements

174
178
180
180
180
181
182
183

184

ImageMap Server Control
Summary

189
192

Chapter 4: Validation Server Controls

193

Understanding Validation
Client-Side versus Server-Side Validation
ASP.NET Validation Server Controls

193
194
195

Validation Causes
The RequiredFieldValidator Server Control
The CompareValidator Server Control
The RangeValidator Server Control
The RegularExpressionValidator Server Control
The CustomValidator Server Control
The ValidationSummary Server Control

196
197

202
206
209
211
216

Turning Off Client-Side Validation
Using Images and Sounds for Error Notifications
Working with Validation Groups
Summary

220
221
222
227

Chapter 5: Working with Master Pages

229

Why Do You Need Master Pages?
The Basics of Master Pages
Coding a Master Page
Coding a Content Page

229
231
233
235


Mixing Page Types and Languages
Specifying Which Master Page to Use
Working with the Page Title
Working with Controls and Properties from the Master Page

Specifying Default Content in the Master Page
Programmatically Assigning the Master Page
Nesting Master Pages
Container-Specific Master Pages

xii

239
241
242
243

250
251
253
257

5:00pm

Page xii


Evjen ftoc.tex V2 - 01/28/2008

5:00pm


Contents
Event Ordering
Caching with Master Pages
ASP.NET AJAX and Master Pages
Summary

258
259
259
262

Chapter 6: Themes and Skins

263

Using ASP.NET Themes

263

Applying a Theme to a Single ASP.NET Page
Applying a Theme to an Entire Application
Removing Themes from Server Controls
Removing Themes from Web Pages
Understanding Themes When Using Master Pages
Understanding the StyleSheetTheme Attribute

Creating Your Own Themes
Creating the Proper Folder Structure
Creating a Skin

Including CSS Files in Your Themes
Having Your Themes Include Images

Defining Multiple Skin Options
Programmatically Working with Themes
Assigning the Page’s Theme Programmatically
Assigning a Control’s SkinID Programmatically

263
265
266
267
267
268

268
268
269
272
275

278
280
280
281

Themes, Skins, and Custom Controls
Summary

281

286

Chapter 7: Data Binding in ASP.NET 3.5

287

Data Source Controls

287

SqlDataSource Control
LINQ Data Source Control
AccessDataSource Control
XmlDataSource Control
ObjectDataSource Control
SiteMapDataSource Control

289
302
307
307
309
314

Configuring Data Source Control Caching
Storing Connection Information
Using Bound List Controls with Data Source Controls

314
315

317

GridView
Editing GridView Row Data
Deleting GridView Data
DetailsView
Inserting, Updating, and Deleting Data Using DetailsView

318
334
341
344
349

xiii

Page xiii


Evjen

ftoc.tex V2 - 01/28/2008

Contents
ListView
FormView

Other Databound Controls
DropDownList, ListBox, RadioButtonList, and CheckBoxList
TreeView

Ad Rotator
Menu

Inline Data-Binding Syntax
Data-Binding Syntax Changes
XML Data Binding

350
360

365
365
366
366
367

367
368
369

Expressions and Expression Builders
Summary

369
375

Chapter 8: Data Management with ADO.NET

377


Basic ADO.NET Features

378

Common ADO.NET Tasks
Basic ADO.NET Namespaces and Classes
Using the Connection Object
Using the Command Object
Using the DataReader Object
Using Data Adapter
Using Parameters
Understanding DataSet and DataTable
Using Oracle as Your Database with ASP.NET 3.5

The DataList Server Control
Looking at the Available Templates
Working with ItemTemplate
Working with Other Layout Templates
Working with Multiple Columns

The ListView Server Control
Looking at the Available Templates
Using the Templates
Creating the Layout Template
Creating the ItemTemplate
Creating the EditItemTemplate
Creating the EmptyItemTemplate
Creating the InsertItemTemplate
The Results


Using Visual Studio for ADO.NET Tasks
Creating a Connection to the Data Source
Working with a Dataset Designer
Using the CustomerOrders DataSet

xiv

378
383
384
386
387
389
392
395
400

403
403
404
407
409

410
410
411
412
414
415
415

416
416

419
419
422
427

5:00pm

Page xiv


Evjen

ftoc.tex V2 - 01/28/2008

5:00pm Page xv

Contents
Asynchronous Command Execution
Asynchronous Connections

432
454

Summary

454


Chapter 9: Querying with LINQ

455

LINQ to Objects

455

Traditional Query Methods
Replacing Traditional Queries with LINQ
Data Grouping
Other LINQ Operators
LINQ Joins
Paging Using LINQ

LINQ to XML
Joining XML Data

LINQ to SQL
Insert, Update, and Delete Queries through LINQ
Extending LINQ

455
464
472
473
473
475

476

479

481
490
494

Summary

495

Chapter 10: Working with XML and LINQ to XML

497

The Basics of XML

498

The XML InfoSet
XSD–XML Schema Definition
Editing XML and XML Schema in Visual Studio 2008

XmlReader and XmlWriter
Using XDocument Rather Than XmlReader
Using Schema with XmlTextReader
Validating Against a Schema Using an XDocument
Including NameTable Optimization
Retrieving .NET CLR Types from XML
ReadSubtree and XmlSerialization
Creating CLR Objects from XML with LINQ to XML

Creating XML with XmlWriter
Creating XML with LINQ for XML
Improvements for XmlReader and XmlWriter in 2.0

XmlDocument and XPathDocument
Problems with the DOM
XPath, the XPathDocument, and XmlDocument

DataSets
Persisting DataSets to XML
XmlDataDocument

500
501
503

506
508
509
511
513
515
517
518
519
522
524

525
525

525

530
530
531

xv


Evjen

ftoc.tex V2 - 01/28/2008

Contents
The XmlDataSource Control
XSLT
XslCompiledTransform
XSLT Debugging

Databases and XML
FOR XML AUTO
SQL Server 2005 and the XML Data Type

533
537
539
543

544
545

549

Summary

556

Chapter 11: IIS7

557

Modular Architecture of IIS7

557

IIS-WebServer
IIS-WebServerManagementTools
IIS-FTPPublishingService

558
561
562

Extensible Architecture of IIS7
IIS7 and ASP.NET Integrated Pipeline
Building a Customized Web Server

562
562
564


Update Dependencies
Installing IIS7 on Windows Vista
Installing IIS7 on Windows Server 2008
Command-Line Setup Options
Unattended Setup Option
Upgrade

565
565
565
567
568
569

Internet Information Services (IIS) Manager
Application Pools
Web Sites
Hierarchical Configuration
Delegation

569
570
575
577
581

Moving an Application from IIS6 to IIS7
Summary

584

586

Chapter 12: Introduction to the Provider Model

587

Understanding the Provider
The Provider Model in ASP.NET 3.5

588
589

Setting Up Your Provider to Work with Microsoft SQL Server 7.0, 2000, 2005, or 2008
Membership Providers
Role Providers
The Personalization Provider
The SiteMap Provider

xvi

591
598
602
606
608

5:00pm

Page xvi



Evjen ftoc.tex V2 - 01/28/2008

5:00pm

Contents
SessionState Providers
Web Event Providers
Configuration Providers
The WebParts Provider

609
612
620
623

Configuring Providers
Summary

625
626

Chapter 13: Extending the Provider Model

627

Providers Are One Tier in a Larger Architecture
Modifying Through Attribute-Based Programming

627

628

Simpler Password Structures Through the SqlMembershipProvider
Stronger Password Structures Through the SqlMembershipProvider

Examining ProviderBase
Building Your Own Providers
Creating the CustomProviders Application
Constructing the Class Skeleton Required
Creating the XML User Data Store
Defining the Provider Instance in the web.config File
Not Implementing Methods and Properties of the MembershipProvider Class
Implementing Methods and Properties of the MembershipProvider Class
Using the XmlMembershipProvider for User Login

Extending Pre-Existing Providers
Limiting Role Capabilities with a New LimitedSqlRoleProvider Provider
Using the New LimitedSqlRoleProvider Provider

629
632

633
635
635
636
640
641
642
643

651

652
652
656

Summary

660

Chapter 14: Site Navigation

661

XML-Based Site Maps
SiteMapPath Server Control

662
664

The PathSeparator Property
The PathDirection Property
The ParentLevelsDisplayed Property
The ShowToolTips Property
The SiteMapPath Control’s Child Elements

TreeView Server Control
Identifying the TreeView Control’s Built-In Styles
Examining the Parts of the TreeView Control
Binding the TreeView Control to an XML File

Selecting Multiple Options in a TreeView

666
668
669
669
670

670
674
676
676
679

xvii

Page xvii


Evjen

ftoc.tex V2 - 01/28/2008

Contents
Specifying Custom Icons in the TreeView Control
Specifying Lines Used to Connect Nodes
Working with the TreeView Control Programmatically

Menu Server Control
Applying Different Styles to the Menu Control

Menu Events
Binding the Menu Control to an XML File

683
685
687

693
694
700
701

SiteMap Data Provider

703

ShowStartingNode
StartFromCurrentNode
StartingNodeOffset
StartingNodeUrl

703
704
705
706

SiteMap API
URL Mapping
Sitemap Localization
Structuring the Web.sitemap File for Localization

Making Modifications to the Web.config File
Creating Assembly Resource (.resx) Files
Testing the Results

Security Trimming
Setting Up Role Management for Administrators
Setting Up the Administrators’ Section
Enabling Security Trimming

706
709
710
710
711
712
712

714
715
716
718

Nesting SiteMap Files
Summary

720
722

Chapter 15: Personalization


723

The Personalization Model
Creating Personalization Properties

723
725

Adding a Simple Personalization Property
Using Personalization Properties
Adding a Group of Personalization Properties
Using Grouped Personalization Properties
Defining Types for Personalization Properties
Using Custom Types
Providing Default Values
Making Personalization Properties Read-Only

Anonymous Personalization
Enabling Anonymous Identification of the End User
Working with Anonymous Identification
Anonymous Options for Personalization Properties
Warnings about Anonymous User Profile Storage

xviii

725
726
730
731
731

732
735
735

735
736
739
739
740

5:00pm

Page xviii


Evjen

ftoc.tex V2 - 01/28/2008

5:00pm

Contents
Programmatic Access to Personalization
Migrating Anonymous Users
Personalizing Profiles
Determining Whether to Continue with Automatic Saves

Personalization Providers
Working with SQL Server Express Edition
Working with Microsoft’s SQL Server 7.0/2000/2005/2008

Using Multiple Providers

Managing Application Profiles
Properties of the ProfileManger Class
Methods of the ProfileManager Class
Building the ProfileManager.aspx Page
Examining the Code of ProfileManager.aspx Page
Running the ProfileManager.aspx Page

741
741
743
744

745
745
746
748

749
750
750
751
754
755

Summary

755


Chapter 16: Membership and Role Management

757

Authentication
Authorization
ASP.NET 3.5 Authentication

758
758
758

Setting Up Your Web Site for Membership
Adding Users
Asking for Credentials
Working with Authenticated Users
Showing the Number of Users Online
Dealing with Passwords

ASP.NET 3.5 Authorization
Using the LoginView Server Control
Setting Up Your Web Site for Role Management
Adding and Retrieving Application Roles
Deleting Roles
Adding Users to Roles
Getting All the Users of a Particular Role
Getting All the Roles of a Particular User
Removing Users from Roles
Checking Users in Roles
Understanding How Roles Are Cached


Using the Web Site Administration Tool
Public Methods of the Membership API
Public Methods of the Roles API
Summary

758
761
776
784
786
788

793
793
796
799
801
802
803
805
805
806
807

809
809
810
810


xix

Page xix


Evjen

ftoc.tex V2 - 01/28/2008

Contents
Chapter 17: Portal Frameworks and Web Parts

811

Introducing Web Parts
Building Dynamic and Modular Web Sites

811
813

Introducing the WebPartManager Control
Working with Zone Layouts
Understanding the WebPartZone Control
Allowing the User to Change the Mode of the Page
Modifying Zones

813
814
817
820

833

Working with Classes in the Portal Framework
Creating Custom Web Parts
Connecting Web Parts

841
844
850

Building the Provider Web Part
Building the Consumer Web Part
Connecting Web Parts on an ASP.NET Page
Understanding the Difficulties in Dealing with Master Pages When Connecting Web Parts

851
854
856
858

Summary

860

Chapter 18: HTML and CSS Design with ASP.NET

861

Caveats
HTML and CSS Overview


862
862

Introducing CSS
Creating Style Sheets
CSS Rules
CSS Inheritance
Element Layout and Positioning
Working with HTML and CSS in Visual Studio
ASP.NET 2.0 CSS–Friendly Control Adapters

863
863
866
875
876
884
893

Summary

893

Chapter 19: ASP.NET AJAX

895

Understanding the Need for AJAX


895

Before AJAX
AJAX Changes the Story

ASP.NET AJAX and Visual Studio 2008
Client-Side Technologies
Server-Side Technologies
Developing with ASP.NET AJAX

ASP.NET AJAX Applications
Building a Simple ASP.NET Page Without AJAX
Building a Simple ASP.NET Page with AJAX

xx

896
897

899
900
900
901

902
904
906

5:00pm Page xx



Evjen

ftoc.tex V2 - 01/28/2008

5:00pm

Contents
ASP.NET AJAX’s Server-Side Controls
The ScriptManager Control
The ScriptManagerProxy Control
The Timer Control
The UpdatePanel Control
The UpdateProgress Control

911
912
914
916
917
922

Using Multiple UpdatePanel Controls
Summary

925
928

Chapter 20: ASP.NET AJAX Control Toolkit


929

Downloading and Installing

929

New Visual Studio Templates
Adding the New Controls to the VS2008 Toolbox

The ASP.NET AJAX Controls
ASP.NET AJAX Control Toolkit Extenders
AlwaysVisibleControlExtender
AnimationExtender
AutoCompleteExtender
CalendarExtender
CollapsiblePanelExtender
ConfirmButtonExtender and ModalPopupExtender
DragPanelExtender
DropDownExtender
DropShadowExtender
DynamicPopulateExtender
FilteredTextBoxExtender
HoverMenuExtender
ListSearchExtender
MaskedEditExtender and MaskedEditValidator
MutuallyExclusiveCheckBoxExtender
NumericUpDownExtender
PagingBulletedListExtender
PopupControlExtender
ResizableControlExtender

RoundedCornersExtender
SliderExtender
SlideShowExtender
TextBoxWatermarkExtender
ToggleButtonExtender
UpdatePanelAnimationExtender
ValidatorCalloutExtender

931
932

934
937
937
939
941
944
946
947
950
951
953
956
959
961
962
964
967
968
969

970
972
975
976
977
979
982
983
984

xxi

Page xxi


Evjen ftoc.tex V2 - 01/28/2008

Contents
ASP.NET AJAX Control Toolkit Server Controls
Accordion Control
NoBot Control
PasswordStrength Control
Rating Control
TabContainer Control

985
986
988
990
991

993

Summary

994

Chapter 21: Security

995

Authentication and Authorization
Applying Authentication Measures

996
996

The <authentication> Node
Windows-Based Authentication
Forms-Based Authentication
Passport Authentication

Authenticating Specific Files and Folders
Programmatic Authorization
Working with User.Identity
Working with User.IsInRole()
Pulling More Information with WindowsIdentity

Identity and Impersonation
Securing Through IIS
IP Address and Domain Name Restrictions

Working with File Extensions
Using the ASP.NET MMC Snap-In
Using the IIS 7.0 Manager

997
998
1006
1016

1016
1017
1018
1019
1020

1023
1025
1025
1027
1031
1032

Summary

1032

Chapter 22: State Management

1033


What Are Your Choices?
Understanding the Session Object in ASP.NET

1034
1036

Sessions and the Event Model
Configuring Session State Management
In-Process Session State
Out-of-Process Session State
SQL-Backed Session State
Extending Session State with Other Providers
Cookieless Session State
Choosing the Correct Way to Maintain State

1036
1038
1038
1046
1051
1056
1057
1058

The Application Object
QueryStrings

xxii

1059

1060

5:00pm

Page xxii


×