37,99 €
In this book, you'll be introduced to the features andcapabilities of ASP.NET 3.5, as well as the foundation that ASP.NETprovides. Updated for the latest release of Visual Studio, this newedition adds five hundred pages of great new content compared tothe original 2.0 version of the book. Including both printed anddownloadable VB and C# code examples, this edition focuses evenmore on experienced programmers and advanced web development. Newcoverage includes new chapters on IIS 7 development, LINQ, ASP.NET,Silverlight, and many others.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 2113
Veröffentlichungsjahr: 2011
Table of Contents
Title Page
Copyright
About the Authors
Credits
Acknowledgments
Introduction
A Little Bit of History
The Goals of ASP.NET
Additional Features of ASP.NET 3.5
What You Need for ASP.NET 3.5
Who Should Read This Book?
What This Book Covers
Conventions
Source Code
Errata
p2p.wrox.com
Chapter 1: Application and Page Frameworks
Application Location Options
The ASP.NET Page Structure Options
ASP.NET 3.5 Page Directives
ASP.NET Page Events
Dealing with PostBacks
Cross-Page Posting
ASP.NET Application Folders
Compilation
Build Providers
Global.asax
Working with Classes Through VS2008
Summary
Chapter 2: ASP.NET Server Controls and Client-Side Scripts
ASP.NET Server Controls
Applying Styles to Server Controls
HTML Server Controls
Manipulating Pages and Server Controls with JavaScript
Client-Side Callback
Summary
Chapter 3: ASP.NET Web Server Controls
An Overview of Web Server Controls
The Label Server Control
The Literal Server Control
The TextBox Server Control
The Button Server Control
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
The CheckBox Server Control
The CheckBoxList Server Control
The RadioButton Server Control
The RadioButtonList Server Control
Image Server Control
Table Server Control
The Calendar Server Control
AdRotator Server Control
The Xml Server Control
Panel Server Control
The PlaceHolder Server Control
BulletedList Server Control
HiddenField Server Control
FileUpload Server Control
MultiView and View Server Controls
Wizard Server Control
ImageMap Server Control
Summary
Chapter 4: Validation Server Controls
Understanding Validation
Client-Side versus Server-Side Validation
ASP.NET Validation Server Controls
Turning Off Client-Side Validation
Using Images and Sounds for Error Notifications
Working with Validation Groups
Summary
Chapter 5: Working with Master Pages
Why Do You Need Master Pages?
The Basics of Master Pages
Coding a Master Page
Coding a Content Page
Specifying Default Content in the Master Page
Programmatically Assigning the Master Page
Nesting Master Pages
Container-Specific Master Pages
Event Ordering
Caching with Master Pages
ASP.NET AJAX and Master Pages
Summary
Chapter 6: Themes and Skins
Using ASP.NET Themes
Creating Your Own Themes
Defining Multiple Skin Options
Programmatically Working with Themes
Themes, Skins, and Custom Controls
Summary
Chapter 7: Data Binding in ASP.NET 3.5
Data Source Controls
Configuring Data Source Control Caching
Storing Connection Information
Using Bound List Controls with Data Source Controls
Other Databound Controls
Inline Data-Binding Syntax
Expressions and Expression Builders
Summary
Chapter 8: Data Management with ADO.NET
Basic ADO.NET Features
The DataList Server Control
The ListView Server Control
Using Visual Studio for ADO.NET Tasks
Asynchronous Command Execution
Summary
Chapter 9: Querying with LINQ
LINQ to Objects
LINQ to XML
LINQ to SQL
Summary
Chapter 10: Working with XML and LINQ to XML
The Basics of XML
XmlReader and XmlWriter
XmlDocument and XPathDocument
DataSets
The XmlDataSource Control
XSLT
Databases and XML
Summary
Chapter 11: IIS7
Modular Architecture of IIS7
Extensible Architecture of IIS7
IIS7 and ASP.NET Integrated Pipeline
Building a Customized Web Server
Internet Information Services (IIS) Manager
Moving an Application from IIS6 to IIS7
Summary
Chapter 12: Introduction to the Provider Model
Understanding the Provider
The Provider Model in ASP.NET 3.5
Configuring Providers
Summary
Chapter 13: Extending the Provider Model
Providers Are One Tier in a Larger Architecture
Modifying Through Attribute-Based Programming
Examining ProviderBase
Building Your Own Providers
Extending Pre-Existing Providers
Summary
Chapter 14: Site Navigation
XML-Based Site Maps
SiteMapPath Server Control
TreeView Server Control
Menu Server Control
SiteMap Data Provider
SiteMap API
URL Mapping
Sitemap Localization
Security Trimming
Nesting SiteMap Files
Summary
Chapter 15: Personalization
The Personalization Model
Creating Personalization Properties
Anonymous Personalization
Programmatic Access to Personalization
Personalization Providers
Managing Application Profiles
Summary
Chapter 16: Membership and Role Management
Authentication
Authorization
ASP.NET 3.5 Authentication
ASP.NET 3.5 Authorization
Using the Web Site Administration Tool
Public Methods of the Membership API
Public Methods of the Roles API
Summary
Chapter 17: Portal Frameworks and Web Parts
Introducing Web Parts
Building Dynamic and Modular Web Sites
Working with Classes in the Portal Framework
Creating Custom Web Parts
Connecting Web Parts
Summary
Chapter 18: HTML and CSS Design with ASP.NET
Caveats
HTML and CSS Overview
Summary
Chapter 19: ASP.NET AJAX
Understanding the Need for AJAX
ASP.NET AJAX and Visual Studio 2008
ASP.NET AJAX Applications
ASP.NET AJAX's Server-Side Controls
Using Multiple UpdatePanel Controls
Summary
Chapter 20: ASP.NET AJAX Control Toolkit
Downloading and Installing
The ASP.NET AJAX Controls
ASP.NET AJAX Control Toolkit Server Controls
Summary
Chapter 21: Security
Authentication and Authorization
Applying Authentication Measures
Authenticating Specific Files and Folders
Programmatic Authorization
Identity and Impersonation
Securing Through IIS
Summary
Chapter 22: State Management
What Are Your Choices?
Understanding the Session Object in ASP.NET
The Application Object
QueryStrings
Cookies
PostBacks and Cross-Page PostBacks
Hidden Fields, ViewState, and ControlState
Using HttpContext.Current.Items for Very Short-Term Storage
Summary
Chapter 23: Caching
Caching
Caching Programmatically
Using the SQL Server Cache Dependency
Configuring Your ASP.NET Application
Testing SQL Server Cache Invalidation
Summary
Chapter 24: Debugging and Error Handling
Design-Time Support
Tracing
Debugging
Exception and Error Handling
Summary
Chapter 25: File I/O and Streams
Working with Drives, Directories, and Files
Reading and Writing Files
Working with Serial Ports
Network Communications
Summary
Chapter 26: User and Server Controls
User Controls
Server Controls
Summary
Chapter 27: Modules and Handlers
Processing HTTP Requests
HttpModules
Summary
Chapter 28: Using Business Objects
Using Business Objects in ASP.NET 3.5
COM Interop: Using COM Within .NET
Using .NET from Unmanaged Code
Summary
Chapter 29: Building and Consuming Services
Communication Between Disparate Systems
Building a Simple XML Web Service
Consuming a Simple XML Web Service
Transport Protocols for Web Services
Overloading WebMethods
Caching Web Service Responses
SOAP Headers
Consuming Web Services Asynchronously
Windows Communication Foundation
Building the WCF Consumer
Summary
Chapter 30: Localization
Cultures and Regions
ASP.NET 3.5 Resource Files
Looking at the Resource Editor
Summary
Chapter 31: Configuration
Configuration Overview
Common Configuration Settings
Creating Custom Sections
Summary
Chapter 32: Instrumentation
Working with the Event Log
Using Performance Counters
Application Tracing
Understanding Health Monitoring
Summary
Chapter 33: Administration and Management
The ASP.NET Web Site Administration Tool
Configuring ASP.NET in IIS on Vista
Summary
Chapter 34: Packaging and Deploying ASP.NET Applications
Deployment Pieces
Steps to Take before Deploying
Methods of Deploying Web Applications
Looking More Closely at Installer Options
Summary
Appendix A: Migrating Older ASP.NET Projects
Migrating Is Not Difficult
When Mixing Versions—Forms Authentication
Upgrading—ASP.NET Reserved Folders
ASP.NET 3.5 Pages Come as XHTML
No Hard-Coded .js Files in ASP.NET 3.5
Converting ASP.NET 1.x Applications in Visual Studio 2008
Migrating from ASP.NET 2.0 to 3.5
Appendix B: ASP.NET Ultimate Tools
Debugging Made Easier
References
Tidying Up Your Code
Visual Studio Add-ins
Extending ASP.NET
General Purpose Developer Tools
Summary
Appendix C: Silverlight
Extending ASP.NET Apps with Silverlight
Summary
Appendix D: ASP.NET Online Resources
Author Blogs
ASP.NET Influential Blogs
Web Sites
Index
Advertisement
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
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 http://www.wiley.com/go/permissions.
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.
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 evjen@yahoo.com.
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 http://www.hanselman.com and podcasts at http://www.hanselminutes.com and contributes to http://www.asp.net, http://www.windowsclient.net, and http://www.silverlight.net.
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.
Credits
Acquisitions Director
Jim Minatel
Development Editors
Adaobi Obi Tulton
Sydney Jones
Technical Editors
Eric Engler
Alexei Gorkov
Doug Holland
Darren Kindberg
Mark Strawmeyr
Production Editor
Angela Smith
Copy Editors
Nancy Rapoport
Sydney Jones
Editorial Manager
Mary Beth Wakefield
Production Manager
Tim Tate
Vice President and Executive Group Publisher
Richard Swadley
Vice President and Executive Publisher
Joseph B. Wikert
Project Coordinator, Cover
Lynsey Stanford
Proofreader
Sossity Smith
Indexer
J & J Indexing
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
Introduction
Simply put, you will find that ASP.NET 3.5 is an amazing technology to use to build your Web solutions! When ASP.NET 1.0 was introduced in 2000, many considered it a revolutionary leap forward in the area of Web application development. ASP.NET 2.0 was just as exciting and revolutionary and ASP.NET 3.5 is continuing a forward march in providing the best framework today in building applications for the Web. Although the foundation of ASP.NET was laid with the release of ASP.NET 1.0, ASP.NET 3.5 continues to build on this foundation by focusing on the area of developer productivity.
This book covers the whole of ASP.NET. It not only introduces new topics, it also shows you examples of these new technologies in action. So sit back, pull up that keyboard, and let's have some fun!
A Little Bit of History
Before organizations were even thinking about developing applications for the Internet, much of the application development focused on thick desktop applications. These thick-client applications were used for everything from home computing and gaming to office productivity and more. No end was in sight for the popularity of this application model.
During that time, Microsoft developers developed its thick-client applications using mainly Visual Basic (VB).
Visual Basic was not only a programming language; it was tied to an IDE that allowed for easy thick-client application development. In the Visual Basic model, developers could drop controls onto a form, set properties for these controls, and provide code behind them to manipulate the events of the control. For example, when an end user clicked a button on one of the Visual Basic forms, the code behind the form handled the event.
Then, in the mid-1990s, the Internet arrived on the scene. Microsoft was unable to move the Visual Basic model to the development of Internet-based applications. The Internet definitely had a lot of power, and right away, the problems facing the thick-client application model were revealed. Internet-based applications created a single instance of the application that everyone could access. Having one instance of an application meant that when the application was upgraded or patched, the changes made to this single instance were immediately available to each and every user visiting the application through a browser.
To participate in the Web application world, Microsoft developed Active Server Pages (ASP). ASP was a quick and easy way to develop Web pages. ASP pages consisted of a single page that contained a mix of markup and languages. The power of ASP was that you could include VBScript or JScript code instructions in the page executed on the Web server before the page was sent to the end user's Web browser. This was an easy way to create dynamic Web pages customized based on instructions dictated by the developer.
ASP used script between brackets and percentage signs—<% %>—to control server-side behaviors. A developer could then build an ASP page by starting with a set of static HTML. Any dynamic element needed by the page was defined using a scripting language (such as VBScript or JScript). When a user requested the page from the server by using a browser, the asp.dll (an ISAPI application that provided a bridge between the scripting language and the Web server) would take hold of the page and define all the dynamic aspects of the page on-the-fly based on the programming logic specified in the script. After all the dynamic aspects of the page were defined, the result was an HTML page output to the browser of the requesting client.
As the Web application model developed, more and more languages mixed in with the static HTML to help manipulate the behavior and look of the output page. Over time, such a large number of languages, scripts, and plain text could be placed in a typical ASP page that developers began to refer to pages that utilized these features as spaghetti code. For example, it was quite possible to have a page that used HTML, VBScript, JavaScript, Cascading Style Sheets, T-SQL, and more. In certain instances, it became a manageability nightmare.
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!