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