logo资料库

Beginning ASP.NET for Visual Studio 2015 无水印pdf.pdf

第1页 / 共793页
第2页 / 共793页
第3页 / 共793页
第4页 / 共793页
第5页 / 共793页
第6页 / 共793页
第7页 / 共793页
第8页 / 共793页
资料共793页,剩余部分请下载后查看
Cover
Copyright
Contents
Introduction
1 Getting Started with ASP.NET 6.0
An Introduction to ASP.NET vNext
Hypertext Transfer Protocol (HTTP)
Microsoft Internet Information Services
HTML 5
HTML Markup
Attributes in HTML
HTML Example
ASP.NET Web Forms
ViewState
ASP.NET Web Forms Events and Page Lifecycle
Control Library
ASP.NET MVC
Testability
Full Control over Output
Web Forms and MVC Similarities
Choosing the Best Approach
Using Visual Studio 2015
Versions
Downloading and Installing
The Sample Application
Summary
2 Building an Initial ASP.NET Application
Creating Websites with Visual Studio 2015
Available Project Types
Web Site Project–Based Approach
Web Application Project
Creating a New Site
While Creating a Project
Empty Template
Web Forms Template
MVC Template
Web API Template
Single Page Application Template
Azure Mobile Service Template
Working with Files in Your Application
File Types of an ASP.NET MVC Application
File System Structure of an ASP.NET MVC Application
File Types of an ASP.NET Web Forms Application
MVC and Web Form File Differences
Creating the Sample Application
Summary
3 Designing Your Web Pages
HTML and CSS
Why Use Both HTML and CSS?
An Introduction to CSS
More CSS
Selectors
Properties
Precedence in Styles
The Style Sheet
Adding CSS to Your Pages
Creating Embedded and Inline Style Sheets
Applying Styles
Managing Styles
Summary
4 Programming in C# and VB.NET
Introduction to Programming
Data Types and Variables
Defining a Variable
Operators
Converting and Casting Data Types
Converting Data Types
Casting Data Types
Using Arrays and Collections
Using Arrays
Using Collections
Decision-Making Operations
Comparison Operators
Logical Operators
If Statement
Switch/Select Case Statement
Loops
For Loop
Foreach/For Each Loops
While Loop
Exiting Loops
Organizing Code
Methods: Functions and Subroutines
Writing Comments and Documentation
Object-Oriented Programming Basics
Important OO Terminology
Classes
Fields
Properties
Methods
Constructors
Inheritance
Events
Summary
5 ASP.NET Web Form Server Controls
Introduction to Server Controls
Defining Controls in Your Pages
Types of Controls
Standard Controls
HTML Controls
Data Controls
Validation Controls
Navigation Controls
Login Controls
AJAX Extensions
Other Control Sets
The ASP.NET State Engine
How the State Engine Works
Summary
6 ASP.NET MVC Helpers and Extensions
Why MVC Has Fewer Controls Than Web Forms
A Different Approach
Razor
Controller
Routing
HTTP Verbs and Attributes
Form-Building Helpers
Form Extensions
Editor and EditorFor
Model Binding
Summary
7 Creating Consistent-Looking Websites
Consistent Page Layout with Master Pages
Creating and Using Master Pages in ASP.NET Web Forms
Creating a Content Page in ASP.NET Web Forms
Creating Layouts in ASP.NET MVC
Creating a Content View in ASP.NET MVC
Using a Centralized Base Page
Summary
8 Navigation
Different Ways to Move around Your Site
Understanding Absolute and Relative URLs
Understanding Default Documents
Friendly URLs
Using the ASP.NET Web Forms Navigation Controls
Using the Menu Control
Navigating in ASP.NET MVC
Routing
Default Configuration and Route
Creating a Navigational Structure
Programmatic Redirection
Programmatically Redirecting the Client to a Different Page
Server-Side Redirects
Practical Tips on Navigation
Summary
9 Displaying and Updating Data
Working with SQL Server Express
Installation
SQL Server Management Studio
Connecting in Visual Studio
Entity Framework Approach to Data Access
Data First
Code First
Selecting Data from the Database
Data Controls in Web Forms
Details View
Web Form GridView
Data Display in MVC
List Display in MVC
Details Views
Summary
10 Working with Data—Advanced Topics
Sorting and Pagination
Sorting and Pagination in Web Form Server Controls
Sorting and Pagination in MVC Lists
Updating and/or Inserting Data
A Non-Code First Approach to Database Access
Using SQL Queries and Stored Procedures
Caching
Different Ways to Cache Data in ASP.NET Applications
Common Pitfalls with Caching Data
Summary
11 User Controls and Partial Views
Introduction to User Controls
Creating User Controls
Adding User Controls
Sitewide Registration of a User Control
Managing the IDs of Any Controls
Adding Logic to Your User Controls
Using Partial Views
Adding a Partial View
Managing the Controller for a Partial View
Templates
Summary
12 Validating User Input
Gathering Data from the User
Validating User Input in Web Forms
Understanding Request Validation
Validating User Input in MVC
Model Attribution
Client-Side Validation
Request Validation in ASP.NET MVC
Validation Tips
Summary
13 ASP.NET AJAX
Introducing the Concept of AJAX
F12 Developer Tools
Using ASP.NET AJAX in Web Forms
The Initial AJAX Experience
Enhancing the AJAX Experience
Using AJAX in MVC
Using Web Services in AJAX Websites
jQuery in AJAX
Practical AJAX Tips
Summary
14 JQuery
An Introduction to jQuery
Early JavaScript
jQuery's Role
Including the jQuery Library
Bundles
jQuery Syntax
jQuery Core
Working with the jQuery Utility Methods
Selecting Items Using jQuery
Modifying the DOM with jQuery
Changing Appearance with jQuery
Handling Events
Debugging jQuery
Practical Tips on jQuery
Summary
15 Security in Your ASP.NET Website
Introducing Security
Identity: Who Are You?
Authentication: How Can Users Prove Who They Are?
Authorization: What Are You Allowed to Do?
Logging in with ASP.NET
Configuring Your Web Application for Security
Working with Users within Your Application
Roles
Configuring Your Application to Work with Roles
Programmatically Checking Roles
Practical Security Tips
Summary
16 Personalizing Websites
Understanding the Profile
Creating the Profile
Using the Profile
Practical Personalization Tips
Summary
17 Exception Handling, Debugging, and Tracing
Error Handling
Different Types of Errors
Syntax Errors
Logic Errors
Runtime Errors
Catching and Handling Exceptions
Global Error Handling and Custom Error Pages
Error Handling in a Controller
The Basics of Debugging
Tools Support for Debugging
Moving Around in Debugged Code
Debugging Windows
Other Windows
Debugging Client-Side Script
Tracing Your ASP.NET Web Pages
Adding Your Own Information to the Trace
Tracing and Performance
Logging
Downloading, Installing, and Configuring a Logger
Summary
18 Working with Source Control
Introducing Team Foundation Services
Why Use Source Control
Setting Up a Visual Studio Online Account
Checking Code In and Out
Undoing Changes
Shelvesets
Getting a Specific Version from the Server
Seeing Changed Items in Solution Explorer
Looking at History and Comparing Versions
Labeling
Interacting with a Team
Changing Default Source Control Behavior in Visual Studio
Branching and Merging
Summary
19 Deploying Your WEBSITE
Preparing Your Website for Deployment
Avoiding Hard-Coded Settings
The Web.config File
Expression Syntax
The Web Configuration Manager Class
Preparing for Deployment
Microsoft Azure
Publishing Your Site
Introducing Web.config Transformations
Moving Data to a Remote Server
Smoke Testing Your Application
Going Forward
Summary
Answers to Exercises
Index
EULA
ffi rs.indd 12/18/2015 Page ii
ffi rs.indd 12/18/2015 Page i BEGINNING ASP.NET FOR VISUAL STUDIO® 2015 INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi CHAPTER 1 Getting Started with ASP.NET 6.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 CHAPTER 2 Building an Initial ASP.NET Application . . . . . . . . . . . . . . . . . . . . . . . 27 CHAPTER 3 Designing Your Web Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 CHAPTER 4 Programming in C# and VB.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 CHAPTER 5 ASP.NET Web Form Server Controls . . . . . . . . . . . . . . . . . . . . . . . 129 CHAPTER 6 ASP.NET MVC Helpers and Extensions . . . . . . . . . . . . . . . . . . . . . 161 CHAPTER 7 Creating Consistent-Looking Websites . . . . . . . . . . . . . . . . . . . . . 197 CHAPTER 8 Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 CHAPTER 9 Displaying and Updating Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 CHAPTER 10 Working with Data—Advanced Topics . . . . . . . . . . . . . . . . . . . . . . 323 CHAPTER 11 User Controls and Partial Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 CHAPTER 12 Validating User Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413 CHAPTER 13 ASP.NET AJAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449 CHAPTER 14 jQuery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499 CHAPTER 15 Security in Your ASP.NET Website . . . . . . . . . . . . . . . . . . . . . . . . . 541 CHAPTER 16 Personalizing Websites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581 CHAPTER 17 Exception Handling, Debugging, and Tracing . . . . . . . . . . . . . . . . 605 CHAPTER 18 Working with Source Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661 CHAPTER 19 Deploying Your Website. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683 APPENDIX Answers to Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725 INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735
ffi rs.indd 12/18/2015 Page ii
ffi rs.indd 12/18/2015 Page iii BEGINNING ASP.NET for Visual Studio® 2015
ffi rs.indd 12/18/2015 Page iv
ffi rs.indd 12/18/2015 Page v BEGINNING ASP.NET for Visual Studio® 2015 William Penberthy
ffi rs.indd 12/18/2015 Page vi Beginning ASP.NET for Visual Studio® 2015 Published by John Wiley & Sons, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2016 by John Wiley & Sons, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-1-119-07742-8 ISBN: 978-1-119-07712-1 (ebk) ISBN: 978-1-119-07723-7 (ebk) Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 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 Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748- 6008, 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 specifi cally disclaim all warranties, including without limitation warranties of fi tness for a particular purpose. No warranty may be created or extended by sales or pro- motional 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 pub- lisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site 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 Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web sites 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 (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002. Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with stan- dard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://book- support.wiley.com. For more information about Wiley products, visit www.wiley.com. Library of Congress Control Number: 2015955845 Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are trade- marks or registered trademarks of John Wiley & Sons, Inc. and/or its affi liates, in the United States and other countries, and may not be used without written permission. Visual Studio is a registered trademark of Microsoft Corporation. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc., is not associated with any product or vendor mentioned in this book.
分享到:
收藏