did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

We're the #1 textbook rental company. Let us show you why.

9781118311820

Professional ASP.NET 4.5 in C# and VB

by ; ; ; ;
  • ISBN13:

    9781118311820

  • ISBN10:

    1118311825

  • Format: Paperback
  • Copyright: 2013-05-06
  • Publisher: Wrox

Note: Supplemental materials are not guaranteed with Rental or Used book purchases.

Purchase Benefits

  • Free Shipping Icon Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • eCampus.com Logo Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $59.99 Save up to $16.13
  • Buy Used
    $44.99
    Add to Cart Free Shipping Icon Free Shipping

    USUALLY SHIPS IN 2-4 BUSINESS DAYS

Supplemental Materials

What is included with this book?

Summary

The all-new approach for experienced ASP.NET professionals!

ASP.NET is Microsoft's technology for building dynamically generated web pages from database content. Originally introduced in 2002, ASP.NET has undergone many changes in multiple versions and iterations as developers have gained a decade of experience with this popular technology. With that decade of experience, this edition of the book presents a fresh, new overhauled approach.

  • A new focus on how to build ASP.NET sites and applications relying on field-tested reliable methods
  • Integration of "One ASP.NET" philosophy treating ASP.NET Web Forms and ASP.NET MVC as equal tools each with their proper time and place
  • Coverage of hot new ASP.NET 4.5 additions such as the Web API, Websockets and HTML5 & CSS3 use in layout but only to the extent that the tools themselves are practical and useful for working ASP.NET developers

Professional ASP.NET 4.5 in C# and VB is an essential tool for programmers who need to be productive and build reliably performing sites with the latest ASP.NET Framework and Visual Studio.

Author Biography

Jason N. Gaylord is Director of Technology at United One Resources, an app developer, blogger, Microsoft MVP, and ASPInsider.

Christian Wenz is a consultant, trainer, author, ASP.NET MVP, and ASPInsider.

Pranav Rastogi is a member of the Microsoft ASP.NET team, web developer, and speaker.

Todd Miranda is the owner of NxtDimension Solutions and a consultant, trainer, and Microsoft MVP.

Scott Hanselman is a web developer for Microsoft, has a popular blog and podcast, has authored many books, and speaks globally.

Wrox Professional guides are written by working developers to address everyday needs. They provide examples, practical solutions, and expert education in new technologies, all designed to help programmers do a better job.

Table of Contents

FOREWORD xli

INTRODUCTION xliii

PART I: ASP.NET FUNDAMENTALS

CHAPTER 1: ONE ASP.NET 3

Introducing One ASP.NET 3

Evolution of ASP.NET 4

The Web Evolves and We Evolve with It 5

Simplifying a Complex Ecosystem 6

Web Ecosystem 7

Getting Started Is Easy 8

Integrating the Ecosystem Is Easy 9

Real-World Example 11

How Do You Benefi t? 14

ASP.NET Makes Getting Started Easy 14

ASP.NET Supports the Web Ecosystem 14

ASP.NET Makes Finding, Adding, and Updating Lego

Blocks to Your Site Easy 15

ASP.NET Helps You Apply Concepts from One Framework to Another 15

ASP.NET Moves as Fast as the Web 15

Summary 16

CHAPTER 2: HTML5 AND CSS3 DESIGN WITH ASP.NET 17

Caveats 18

HTML5 Overview 18

New Elements, Attributes, and Values in HTML5 19

Using the New HTML5 Markup 22

New APIs in HTML5 23

CSS3 Overview 24

Creating Style Sheets 25

CSS Rules 27

CSS Inheritance 34

Element Layout and Positioning 35

New Features in CSS3 41

HTML and CSS Compatibility 45

Working with HTML and CSS in Visual Studio 46

Working with CSS in Visual Studio 46

Styling ASP.NET Controls 48

HTML and CSS Improvements in Visual Studio 2012 50

Page Inspector 51

Summary 52

CHAPTER 3: ASP.NET WEB FORMS STRUCTURE 53

Application Location Options 53

Using File System (IIS Express) 54

Using IIS 55

Using FTP 56

The ASP.NET Page Structure Options 57

Inline Coding 57

Code-Behind Model 59

ASP.NET 4.5 Page Directives 61

@Page 62

@Master 64

@Control 66

@Import 67

@Implements 69

@Register 69

@Assembly 70

@PreviousPageType 70

@MasterType 70

@OutputCache 71

@Reference 71

ASP.NET Page Events 71

Dealing with Postbacks 73

Cross-Page Posting 73

ASP.NET Application Folders 78

App_Code Folder 78

App_Data Folder 82

App_GlobalResources Folder 82

App_LocalResources Folder 83

App_WebReferences Folder 83

App_Browsers Folder 83

Compilation 83

Build Providers 87

Using the Built-In Build Providers 88

Using Your Own Build Providers 89

Global.asax 93

Working with Classes through Visual Studio 2012 96

Summary 99

PART II: CONTROLS

CHAPTER 4: ASP.NET SERVER CONTROLS

AND CLIENT-SIDE SCRIPTS 103

ASP.NET Server Controls 104

Types of Server Controls 104

Building with Server Controls 105

Working with Server Control Events 107

Applying Styles to Server Controls 108

HTML Server Controls 111

Looking at the HtmlControl Base Class 112

Looking at the HtmlContainerControl Class 113

Looking at All of the HTML Classes 113

Using the HtmlGenericControl Class 114

Identifying ASP.NET Server Controls 115

Manipulating Pages and Server Controls

with JavaScript 117

Using Page.ClientScript.RegisterClientScriptBlock 119

Using Page.ClientScript.RegisterStartupScript 120

Using Page.ClientScript.RegisterClientScriptInclude 122

Summary 122

CHAPTER 5: ASP.NET WEB SERVER CONTROLS 123

An Overview of Web Server Controls 124

The Label Server Control 124

The Literal Server Control 126

The TextBox Server Control 127

Using the Focus() Method 127

Using Auto Post Back 128

Using Auto Complete Type 129

The Button Server Control 130

The Causes Validation Property 130

The Command Name Property 130

Buttons That Work with Client-Side JavaScript 131

The LinkButton Server Control 133

The ImageButton Server Control 134

The HyperLink Server Control 134

The DropDownList Server Control 135

Visually Removing Items from a Collection 137

The ListBox Server Control 139

Allowing Users to Select Multiple Items 139

An Example of Using the ListBox Control 139

Adding Items to a Collection 141

The CheckBox Server Control 142

How to Determine Whether Check Boxes Are Checked 143

Assigning a Value to a Check Box 143

Aligning Text around the Check Box 144

The CheckBoxList Server Control 144

The RadioButton Server Control 146

The RadioButtonList Server Control 148

Image Server Control 149

Table Server Control 151

The Calendar Server Control 153

Making a Date Selection from the Calendar Control 153

Choosing a Date Format to Output from the Calendar 154

Making Day, Week, or Month Selections 155

Working with Date Ranges 155

Modifying the Style and Behavior of Your Calendar 157

AdRotator Server Control 160

The Xml Server Control 161

Panel Server Control 162

The PlaceHolder Server Control 164

BulletedList Server Control 165

HiddenField Server Control 171

FileUpload Server Control 172

Uploading Files Using the FileUpload Control 172

Giving ASP.NET Proper Permissions to Upload Files 175

Understanding File Size Limitations 176

Uploading Multiple Files from the Same Page 177

Placing the Uploaded File into a Stream Object 180

Moving File Contents from a Stream Object to a Byte Array 181

MultiView and View Server Controls 181

Wizard Server Control 185

Customizing the Side Navigation 186

Examining the Allow Return Attribute 187

Working with the Step Type Attribute 187

Adding a Header to the Wizard Control 188

Working with the Wizard’s Navigation System 189

Utilizing Wizard Control Events 190

Using the Wizard Control to Show Form Elements 191

ImageMap Server Control 196

Summary 198

CHAPTER 6: VALIDATION SERVER CONTROLS 199

Understanding Validation 199

Client-Side versus Server-Side Validation 200

ASP.NET Validation Server Controls 201

Validation Causes 202

Unobtrusive Validation in ASP.NET 4.5 203

The Required Field Validator Server Control 205

The Compare Validator Server Control 209

The Range Validator Server Control 212

The Regular Expression Validator Server Control 216

The Custom Validator Server Control 217

The Validation Summary Server Control 222

Turning Off Client-Side Validation 224

Using Images and Sounds for Error Notifications 225

Working with Validation Groups 227

Summary 230

CHAPTER 7: USER AND SERVER CONTROLS 231

User Controls 232

Creating User Controls 232

Interacting with User Controls 234

Loading User Controls Dynamically 235

Server Controls 240

Server Control Projects 240

Control Attributes 244

Control Rendering 245

Styling HTML 251

Adding Client-Side Features 253

Browser Capabilities 261

Using View State 263

Raising Postback Events 267

Handling Postback Data 270

Composite Controls 273

Templated Controls 275

Design-Time Experiences 279

Summary 296

PART III: DATA ACCESS

CHAPTER 8: DATA BINDING 299

Data Source Controls 299

Sql Data Source Control 301

Access Data Source Control 307

Linq Data Source Control 307

Entity Data Source Control 307

Using the Query Extender for Complex Filters 309

Xml Data Source Control 310

Object Data Source Control 311

Site Map Data Source Control 313

Data Source Control Caching 313

Data-Bound Controls 314

GridView 314

Editing GridView Row Data 323

Deleting GridView Data 329

Details View 330

Inserting, Updating, and Deleting Data Using Details View 333

List View 334

Form View 340

Other Data-Bound Controls 343

Tree View 343

Menu 344

Chart 344

Inline Data-Binding Syntax 347

Data-Binding Syntax 348

XML Data Binding 348

Using Expressions and Expression Builders 349

Summary 353

CHAPTER 9: MODEL BINDING 355

Model Binding 355

Selecting Data 356

Paging 357

Filtering 357

Using Value Providers 358

Inserting Data 359

Updating Data 360

Using Strongly Typed Controls 362

Extending Model Binding 363

Custom Value Providers 363

Custom Model Binders 365

Custom Model Data Source 367

Summary 369

CHAPTER 10: QUERYING WITH LINQ 371

LINQ to Objects 372

Understanding Traditional Query Methods 372

Replacing Traditional Queries with LINQ 376

Grouping Data Using LINQ 384

Using Other LINQ Operators 385

Making LINQ Joins 386

Paging Using LINQ 387

LINQ to XML 388

A Simple LINQ to XML Example 389

Joining XML Data 392

LINQ to SQL 393

Using the O/R Mapper 393

Accessing and Querying Data 395

Using Other SQL Query Methods 399

Making Insert, Update, and Delete Queries through LINQ 401

LINQ to Entities 405

Creating an Entity Framework Data Model 406

Accessing Data 406

Writing LINQ Queries 407

Summary 409

CHAPTER 11: ENTITY FRAMEWORK 411

Can We Speak the Same Language? 412

Development Workflow Options 413

The Entity Data Model 414

Creating Your First Entity Data Model 414

Working through the EDM Wizard 416

Using the Entity Framework Designer 418

Building an ASP.NET Web Form Using Your EDM 420

Understanding Relationships 422

One-to-One and One-to-Many Relationships 422

Many-to-One and Many-to-Many Relationships 425

Performing Inheritance within the EDM 427

Using the Entity Data Source Control 430

Creating the Base Page 430

Configuring the Data Source Control 431

Entity Framework Code First 433

Creating a Code First Model 433

Convention over Configuration 437

Relationships in Code First 437

Code First Migrations 440

Summary 442

CHAPTER 12: ASP.NET DYNAMIC DATA 443

Dynamic Data Features 443

Looking at the Core Files Created in the Default Application 443

Application Features 444

Running the Application 445

Results of the Application 445

Adding Dynamic Data to an Existing Application 448

Understanding Model Binding 449

Attribute Driven UI 450

Attribute Driven Validation 452

Summary 453

CHAPTER 13: WORKING WITH SERVICES 455

Communication between Disparate Systems 455

Building a Simple XML Web Service 457

The Web Service Page Directive 458

Looking at the Base Web Service Class File 458

Exposing Custom Datasets as SOAP 459

The XML Web Service Interface 462

Consuming a Simple XML Web Service 464

Adding a Web Reference 464

Invoking the Web Service from the Client Application 466

Overloading Web Methods 468

Caching Web Service Responses 472

Using SOAP Headers 472

Building a Web Service with SOAP Headers 473

Consuming a Web Service Using SOAP Headers 474

Requesting Web Services Using SOAP 1.2 476

Consuming Web Services Asynchronously 478

Windows Communication Foundation 480

WCF Overview 481

Building a WCF Service 481

Building the WCF Consumer 488

Adding a Service Reference 488

Working with Data Contracts 490

Defining Name spaces 495

Using WCF Data Services 495

Creating Your First Service 496

Querying the Interface 502

Consuming WCF Data Services in ASP.NET 512

ASP.NET Web API 515

Building Your First Web API 515

Understanding Web API Routing 520

Consuming a Web API 521

Summary 525

PART IV: PROVIDERS

CHAPTER 14: INTRODUCTION TO THE PROVIDER MODEL 529

Understanding the Provider 530

The Provider Model in ASP.NET 4.5 531

Setting Up Your Provider to Work with Microsoft SQL Server

2005, 2008, or 2012 532

Membership Providers 537

Role Providers 540

The Personalization Provider 544

The Site Map Provider 545

Session State Providers 546

Web Event Providers 548

Configuration Providers 554

Summary 557

CHAPTER 15: EXTENDING THE PROVIDER MODEL 559

Providers Are One Tier in a Larger Architecture 559

Modifying through Attribute-Based Programming 560

Simpler Password Structures through the Sql Membership Provider 561

Stronger Password Structures through the Sql Membership Provider 563

Examining ProviderBase 564

Building Your Own Providers 566

Creating the CustomProviders Application 566

Constructing the Class Skeleton Required 567

Creating the XML User Data Store 570

Defining the Provider Instance in the web.config File 570

Not Implementing Methods and Properties

of the Membership Provider Class 571

Implementing Methods and Properties

of the Membership Provider Class 572

Using the Xml Membership Provider for User Login 579

Extending Preexisting Providers 580

Limiting Role Capabilities with a New Limited Sql Role Provider Provider 581

Using the New LimitedSqlRoleProvider Provider 584

Summary 588

PART V: ASP.NET FEATURES

CHAPTER 16: WORKING WITH MASTER PAGES 591

Why Do You Need Master Pages? 592

The Basics of Master Pages 593

Coding a Master Page 594

Coding a Content Page 597

Mixing Page Types and Languages 600

Specifying Which Master Page to Use 601

Applying the Master Page Template to a Subset of Pages 602

Working with the Page Title 602

Working with Controls and Properties from the Master Page 603

Specifying Default Content in the Master Page 609

Programmatically Assigning the Master Page 611

Nesting Master Pages 611

Container-Specifi c Master Pages 615

Event Ordering 616

Caching with Master Pages 617

ASP.NET AJAX and Master Pages 618

Summary 620

CHAPTER 17: SITE NAVIGATION 621

XML-Based Sitemaps 622

Site Map Path Server Control 623

The Path Separator Property 625

The Path Direction Property 627

The Parent Levels Displayed Property 627

The Show Tool Tips Property 628

The Site Map Path Control’s Child Elements 628

TreeView Server Control 629

Identifying the TreeView Control’s Built-In Styles 632

Examining the Parts of the TreeView Control 633

Binding the TreeView Control to an XML File 634

Selecting Multiple Options in a Tree View 636

Specifying Custom Icons in the Tree View Control 639

Specifying Lines Used to Connect Nodes 640

Working with the TreeView Control Programmatically 642

Menu Server Control 647

Applying Diff erent Styles to the Menu Control 648

Using Menu Events 652

Binding the Menu Control to an XML File 652

Site Map Data Provider 654

Show Starting Node 654

Start From Current Node 655

Starting Node Off set 656

Starting Node Url 656

SiteMap API 657

URL Mapping 659

Sitemap Localization 660

Structuring the Web.sitemap File for Localization 660

Making Modifications to the web.config File 661

Creating Assembly Resource (.resx) Files 661

Testing the Results 662

Security Trimming 663

Setting Up Role Management for Administrators 664

Setting Up the Administrators’ Section 665

Enabling Security Trimming 666

Nesting SiteMap Files 668

Summary 669

CHAPTER 18: PERSONALIZATION 671

The Personalization Model 672

Creating Personalization Properties 672

Adding a Simple Personalization Property 672

Using Personalization Properties 673

Adding a Group of Personalization Properties 676

Using Grouped Personalization Properties 677

Defining Types for Personalization Properties 678

Using Custom Types 678

Providing Default Values 680

Making Personalization Properties Read-Only 681

Anonymous Personalization 681

Enabling Anonymous Identification of the End User 681

Working with Anonymous Identification 683

Anonymous Options for Personalization Properties 684

Warnings about Anonymous User Profile Storage 685

Programmatic Access to Personalization 685

Migrating Anonymous Users 685

Personalizing Profiles 687

Determining Whether to Continue with Automatic Saves 687

Using Profile Information in Web Application Projects 688

Personalization Providers 690

Working with SQL Server Express Edition 691

Working with Microsoft SQL Server 692

Using Multiple Providers 693

Using Universal Providers 694

Managing Application Profiles 695

Properties of the ProfileManager Class 695

Methods of the ProfileManager Class 695

Building the Profile Manager Page 696

Examining the Profile Manager Page’s Code 698

Running the Profile Manager Page 700

Summary 700

CHAPTER 19: MEMBERSHIP AND ROLE MANAGEMENT 701

ASP.NET 4.5 Authentication 702

Setting Up Your Website for Membership 702

Adding Users 705

Asking for Credentials 718

Working with Authenticated Users 725

Showing the Number of Users Online 727

Dealing with Passwords 728

ASP.NET 4.5 Authorization 732

Using the LoginView Server Control 732

Setting Up Your Website for Role Management 734

Adding and Retrieving Application Roles 737

Deleting Roles 739

Adding Users to Roles 739

Getting All the Users of a Particular Role 740

Getting All the Roles of a Particular User 741

Removing Users from Roles 743

Checking Users in Roles 743

Understanding How Roles Are Cached 744

Using the SimpleMembership API 745

Using the Web Site Administration Tool 746

Public Methods of the Membership API 746

Public Methods of the Roles API 747

Integrating OAuth and OpenID Authentication 748

Using OpenID 748

Using OAuth 752

Summary 758

CHAPTER 20: SECURITY 759

Applying Authentication Measures 760

The <authentication> Node 761

Windows-Based Authentication 761

Forms-Based Authentication 768

Authenticating Specifi c Files and Folders 776

Programmatic Authorization 777

Working with User.Identity 777

Working with User.IsInRole() 779

Pulling More Information with WindowsIdentity 779

Identity and Impersonation 782

Securing through IIS 784

Working with File Extensions 784

Using the IIS 7.x/8 Manager 786

Using the ASP.NET MMC Snap-In 787

Summary 787

PART VI: APPLICATION STATE

CHAPTER 21: STATE MANAGEMENT 791

Your Session State Choices 792

Understanding the Session Object in ASP.NET 794

Sessions and the Event Model 794

Configuring Session State Management 795

In-Process Session State 795

Out-of-Process Session State 802

SQL-Backed Session State 807

Extending Session State with Other Providers 810

Cookieless Session State 811

Choosing the Correct Way to Maintain State 812

The Application Object 813

QueryStrings 813

Cookies 814

Postbacks and Cross-Page Postbacks 814

Hidden Fields, ViewState, and ControlState 816

Using HttpContext.Current.Items for Very Short-Term Storage 820

Summary 821

CHAPTER 22: CACHING 823

Caching 824

Output Caching 824

Partial Page (UserControl) Caching 827

Post-Cache Substitution 828

HttpCachePolicy and Client-Side Caching 830

Caching Programmatically 832

Data Caching Using the Cache Object 832

Controlling the ASP.NET Cache 833

Cache Dependencies 834

.NET 4.x’s New Object Caching Option 839

Using the SQL Server Cache Dependency 842

Enabling Databases for SQL Server Cache Invalidation 843

Enabling Tables for SQL Server Cache Invalidation 843

Looking at SQL Server 843

Looking at the Tables That Are Enabled 844

Disabling a Table for SQL Server Cache Invalidation 844

Disabling a Database for SQL Server Cache Invalidation 845

SQL Server Cache Invalidation 845

Configuring Your ASP.NET Application 847

Testing SQL Server Cache Invalidation 848

Adding More Than One Table to a Page 850

Attaching SQL Server Cache Dependencies to the Request Object 850

Attaching SQL Server Cache Dependencies to the Cache Object 851

Summary 854

PART VII: CLIENT-SIDE DEVELOPMENT

CHAPTER 23: ASP.NET AJAX 857

Understanding the Need for Ajax 857

Before Ajax 858

Ajax Changes the Story 858

ASP.NET AJAX and Visual Studio 2012 860

Client-Side Technologies 861

Server-Side Technologies 862

Developing with ASP.NET AJAX 862

Building ASP.NET AJAX Applications 862

Building a Simple ASP.NET Page without Ajax 864

Building a Simple ASP.NET Page with Ajax 865

ASP.NET AJAX’s Server-Side Controls 870

The ScriptManager Control 871

The ScriptManagerProxy Control 873

The Timer Control 874

The UpdatePanel Control 875

The UpdateProgress Control 879

Using Multiple UpdatePanel Controls 882

Working with Page History 885

Script Combining 890

Summary 894

CHAPTER 24: AJAX CONTROL TOOLKIT 895

Downloading and Installing the Ajax Control Toolkit 896

The ASP.NET AJAX Controls 898

Ajax Control Toolkit Extenders 899

AlwaysVisibleControlExtender 900

AnimationExtender 902

AutoCompleteExtender 903

BalloonPopupExtender 906

CalendarExtender 907

CollapsiblePanelExtender 908

ColorPickerExtender 910

Confi rmButtonExtender and ModalPopupExtender 911

DragPanelExtender 913

DropDownExtender 914

DropShadowExtender 916

DynamicPopulateExtender 919

FilteredTextBoxExtender 922

HoverMenuExtender 923

ListSearchExtender 925

MaskedEditExtender and MaskedEditValidator 926

MutuallyExclusiveCheckBoxExtender 928

NumericUpDownExtender 929

PagingBulletedListExtender 930

PopupControlExtender 931

ResizableControlExtender 933

RoundedCornersExtender 935

SliderExtender and MultiHandleSliderExtender 936

SlideShowExtender 937

TextBoxWatermarkExtender 939

ToggleButtonExtender 941

UpdatePanelAnimationExtender 942

ValidatorCalloutExtender 944

Ajax Control Toolkit Server Controls 945

Accordion Control 945

CascadingDropDown 947

NoBot Control 950

PasswordStrength Control 952

Rating Control 952

TabContainer Control 954

Summary 955

CHAPTER 25: JQUERY 957

Introduction to jQuery 958

Selecting Elements 962

Modifying Elements 964

Modifying Content 965

Adding and Removing Elements 966

Event Handling 968

Ajax 970

jQuery UI 978

Summary 981

CHAPTER 26: REAL-TIME COMMUNICATION 983

Traditional Real-Time Communication Options 983

Using Comet 984

Polling 985

Server-Sent Events 985

Drawbacks of the Existing Approaches 986

HTML5 WebSockets 986

What Is WebSockets? 986

TCP/IP 987

TCP/HTTP 988

Introducing the WebSockets Protocol 988

WebSockets Data Transfer 990

WebSockets API 991

WebSockets in ASP.NET 4.5 991

Benefi ts of Using WebSockets 995

SignalR 996

What Is SignalR? 997

Server-Side SignalR in ASP.NET 997

Client-Side SignalR in ASP.NET 998

Summary 1000

CHAPTER 27: DEVELOPING WEBSITES WITH MOBILE IN MIND 1001

Facing Mobile Web Design Challenges 1002

Responsive Design and Adaptive Design 1002

Modifying the Viewport 1003

Using CSS Media Queries 1005

ASP.NET Mobile Applications 1007

Detecting Mobile Browsers and Devices 1007

Serving Mobile Master Pages 1007

Creating Mobile Web Forms 1009

Friendly URLs in ASP.NET Web Forms 1011

ASP.NET MVC 4 Mobile Applications 1011

Adaptive Rendering in ASP.NET MVC 4 1012

Creating Mobile-Specifi c Views 1014

Providing Display Modes 1016

Including jQuery Mobile and the ViewSwitcher 1018

Using the Mobile Application Project Template 1022

Testing Your Mobile Applications 1022

Summary 1023

PART VIII: APPLICATION CONFIGURATION AND DEPLOYMENT

CHAPTER 28: CONFIGURATION 1027

Configuration Overview 1027

Server Configuration Files 1028

Application Configuration File 1031

Applying Configuration Settings 1031

Detecting Configuration File Changes 1032

Configuration File Format 1033

Common Configuration Settings 1033

Connection Strings 1034

Configuring Session State 1035

Compilation Configuration 1038

Custom Errors 1040

Authentication 1041

Anonymous Identity 1043

Authorization 1044

Locking-Down Configuration Settings 1046

ASP.NET Page Configuration 1046

Include Files 1048

Configuring ASP.NET Runtime Settings 1049

Configuring the ASP.NET Worker Process 1051

Storing Application-Specific Settings 1053

Programming Configuration Files 1054

Protecting Configuration Settings 1059

Editing Configuration Files 1062

Creating Custom Sections 1063

Using the NameValueFileSectionHandler Object 1064

Using the DictionarySectionHandler Object 1064

Using the SingleTagSectionHandler Object 1065

Using Your Own Custom Configuration Handler 1066

Using Configuration Transforms 1068

Adding web.config Transforms 1068

Updating the Confi g Transform File 1070

Bundling and Minifi cation 1072

What Is Bundling and Minification? 1072

Enabling Bundling and Minification 1073

Summary 1074

CHAPTER 29: DEBUGGING AND ERROR HANDLING 1075

Design-Time Support 1075

Syntax Notifi cations 1076

Immediate and Command Window 1077

Task List 1077

Tracing 1078

System.Diagnostics.Trace and ASP.NET’s Page.Trace 1078

Page-Level Tracing 1079

Application Tracing 1079

Viewing Trace Data 1079

Tracing from Components 1082

Trace Forwarding 1083

TraceListeners 1083

Diagnostic Switches 1087

Web Events 1089

Debugging 1090

What’s Required 1091

Starting a Debugging Session 1092

Tools to Help You with Debugging 1093

Historical Debugging with IntelliTrace 1096

Debugging Multiple Threads 1096

Client-Side JavaScript Debugging 1097

SQL Stored Proc Debugging 1098

Exception and Error Handling 1098

Handling Exceptions on a Page 1099

Handling Application Exceptions 1099

Http Status Codes 1100

Debugging with Page Inspector 1101

Summary 1104

CHAPTER 30: MODULES AND HANDLERS 1105

Processing HTTP Requests 1105

IIS 6 and ASP.NET 1106

IIS 7 and IIS 8 and ASP.NET 1106

ASP.NET Request Processing 1107

Http Modules 1108

Http Handlers 1113

Generic Handlers 1113

Mapping a File Extension in IIS 1118

Summary 1119

CHAPTER 31: ASYNCHRONOUS COMMUNICATION 1121

Asynchronous Programming 1121

Why Async? 1122

When to Write Async Code 1122

History of Async 1122

Early Async 1123

Task and TAP 1124

Async/Await 1124

Async in ASP.NET 1125

Thread Pools 1126

Writing Async Code 1127

Parallelism 1131

Server Configuration 1132

Pitfalls of Using Async 1133

Summary 1133

CHAPTER 32: BUILDING GLOBAL APPLICATIONS 1135

Cultures and Regions 1135

Understanding Culture Types 1136

The ASP.NET Threads 1137

Server-Side Culture Declarations 1140

Client-Side Culture Declarations 1141

Translating Values and Behaviors 1142

ASP.NET 4.5 Resource Files 1152

Making Use of Local Resources 1152

Making Use of Global Resources 1159

Summary 1161

CHAPTER 33: PACKAGING AND DEPLOYING ASP.NET

APPLICATIONS 1163

Deployment Pieces 1164

Steps to Take before Deploying 1164

Methods of Deploying Web Applications 1165

Using XCopy 1165

Using the VS Copy Web Site Option 1167

Deploying a Precompiled Web Application 1170

Building an ASP.NET Web Package 1172

Looking More Closely at Publish Profiles 1175

Deploying to Windows Azure Web Sites 1181

Summary 1184

PART IX: ADDITIONAL ASP.NET TECHNOLOGIES

CHAPTER 34: ASP.NET MVC 1187

Defining Model-View-Controller 1188

MVC on the Web Today 1188

Model-View-Controller and ASP.NET 1189

Serving Methods, Not Files 1189

Is This the Future of Web Forms? 1189

Why Not Web Forms? 1190

ASP.NET MVC Is Totally Diff erent! 1190

Why “(ASP.NET > ASP.NET MVC) == True” 1190

Convention over Configuration 1192

The Third Request Is the Charm 1195

Understanding Routes and URLs 1197

Routing Compared to URL Rewriting 1198

Defining Routes 1198

Controllers 1203

Defining the Controller: The IController Interface 1203

The Controller Class and Actions 1204

Working with Parameters 1205

Working with Multiple Parameters 1206

Views 1207

Specifying a View 1208

ASP.NET MVC Layouts 1209

Strongly Typed Views 1212

Using HTML Helper Methods 1213

HtmlHelper Class and Extension Methods 1213

Summary 1214

CHAPTER 35: ASP.NET WEB PAGES AND RAZOR 1215

Overview of ASP.NET Web Pages 1216

Creating an HTML Form Using Razor 1216

Displaying Data 1221

Validation 1225

Using Layouts 1227

Using Helpers 1229

Core Helpers 1229

Adding Functionality Using Helpers 1232

Creating Custom Helpers 1234

Summary 1235

PART X: APPENDIXES

APPENDIX A: MIGRATING OLDER ASP.NET PROJECTS 1239

Migrating Is Not Diffi cult 1239

Running Multiple Versions of the Framework Side by Side 1240

In-Place Upgrade 1240

Upgrading Your ASP.NET Applications 1240

When Mixing Versions—Forms Authentication 1241

Upgrading—ASP.NET Reserved Folders 1242

ASP.NET 4.5 Pages Come as HTML5 1243

No Hard-Coded .js Files in ASP.NET 4.5 1244

Visual Studio 2012 Project Compatibility 1245

Migrating from ASP.NET 2.0/3.5/4.0 to 4.5 1245

Summary 1246

APPENDIX B: COM INTEGRATION 1247

COM Interop: Using COM within .NET 1247

The Runtime Callable Wrapper 1248

Using COM Objects in ASP.NET Code 1248

Error Handling 1252

Deploying COM Components with .NET Applications 1255

Private Assemblies 1255

Public Assemblies 1256

Summary 1256

APPENDIX C: ASP.NET ULTIMATE TOOLS 1257

Debugging Made Easier 1257

Firebug 1257

YSlow 1258

IE10 Developer Tools 1259

jQuery and jQuery UI 1260

Profilers: dotTrace or ANTS 1260

References 1261

QuirksMode.org and HTMLDog.com 1261

Visibone 1262

www.asp.net 1262

www.webdevchecklist.com 1262

Slow Cheetah 1262

Tidying Up Your Code 1263

Refactor! for ASP.NET from DevExpress 1263

Microsoft Ajax Minifi er—JavaScript Minimizer 1263

Extending ASP.NET 1264

Ajax Control Toolkit 1264

Atif Aziz’s ELMAH—Error Logging Modules and Handlers 1265

Helicon’s ISAPI_Rewrite and IIS7 URLRewrite 1265

General-Purpose Developer Tools 1266

Telerik’s Online Code Converter 1266

Win Merge and Differencing Tools 1266

.NET Refl ector 1266

Process Explorer 1266

Summary 1267

APPENDIX D: ADMINISTRATION AND MANAGEMENT 1269

The ASP.NET Web Site Administration Tool 1269

The Home Tab 1271

The Security Tab 1271

The Application Tab 1280

The Provider Tab 1283

Configuring ASP.NET in IIS on Windows 8 1284

.NET Compilation 1285

.NET Globalization 1286

.NET Profile 1287

.NET Roles 1287

.NET Trust Levels 1288

.NET Users 1289

Application Settings 1290

Connection Strings 1290

Pages and Controls 1291

Providers 1292

Session State 1292

SMTP E-mail 1293

Summary 1293

APPENDIX E: DYNAMIC TYPES AND LANGUAGES 1295

Implicit Types 1295

The Dynamic Language Runtime 1296

Dynamic Lookup 1299

Summary 1303

APPENDIX F: ASP.NET ONLINE RESOURCES 1305

Author Blogs and Twitter IDs 1305

ASP.NET Infl uential Blogs 1305

Websites 1306

Twitter Folks Worth Following 1306

APPENDIX G: VISUAL STUDIO EXTENSIBILITY WITH NUGET 1309

Using NuGet in Visual Studio 1310

Managing NuGet Packages with the Window 1311

Managing NuGet Packages with the Console 1318

Creating a NuGet Package 1321

Creating a NuGet Package from an Assembly 1322

Creating a NuGet Package from a Project 1324

Publishing a NuGet Package 1325

Hosting NuGet Packages 1326

File Share Hosting 1326

IIS Hosting 1327

Extending Visual Studio with NuGet 1329

Creating the Power Shell Script Files 1329

Adding Files to the NuGet Package 1330

Editing the NuGet Package Metadata 1330

Deploy the NuGet Package 1331

Summary 1331

INDEX 1333

Supplemental Materials

What is included with this book?

The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.

The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Rewards Program