Wrox Home  
Search

Topic: ASP.NET

Beginning ASP.NET for Visual Studio 2015 (1119077125) cover image

Beginning ASP.NET for Visual Studio 2015

William Penberthy
ISBN: 978-1-119-07712-1
Wiley E-Text
792 pages
January 2016
Other Available Formats: Paperback
Electronic Version: US $29.99 Purchase This E-book and Learn More

About This Title  |  Errata  |  P2P Forum for This Title
Table of Contents
INTRODUCTION xxi

CHAPTER 1: GETTING STARTED WITH ASP.NET 6.0 1

An Introduction to ASP.NET vNext 2

Hypertext Transfer Protocol (HTTP) 2

Microsoft Internet Information Services 5

HTML 5 5

HTML Markup 5

Attributes in HTML 7

HTML Example 8

ASP.NET Web Forms 10

ViewState 10

ASP.NET Web Forms Events and Page Lifecycle 11

Control Library 13

ASP.NET MVC 15

Testability 16

Full Control over Output 17

Web Forms and MVC Similarities 17

Choosing the Best Approach 17

Using Visual Studio 2015 18

Versions 18

Downloading and Installing 19

The Sample Application 23

Summary 24

CHAPTER 2: BUILDING AN INITIAL ASP.NET APPLICATION 27

Creating Websites with Visual Studio 2015 28

Available Project Types 28

Web Site Project–Based Approach 28

Web Application Project 29

Creating a New Site 30

While Creating a Project 30

Empty Template 34

Web Forms Template 35

MVC Template 36

Web API Template 36

Single Page Application Template 37

Azure Mobile Service Template 38

Working with Files in Your Application 38

File Types of an ASP.NET MVC Application 38

File System Structure of an ASP.NET MVC Application 41

File Types of an ASP.NET Web Forms Application 43

MVC and Web Form File Differences 46

Creating the Sample Application 47

Summary 49

CHAPTER 3: DESIGNING YOUR WEB PAGES 51

HTML and CSS 52

Why Use Both HTML and CSS? 52

An Introduction to CSS 54

More CSS 58

Selectors 58

Properties 61

Precedence in Styles 65

The Style Sheet 67

Adding CSS to Your Pages 68

Creating Embedded and Inline Style Sheets 71

Applying Styles 72

Managing Styles 78

Summary 84

CHAPTER 4: PROGRAMMING IN C# AND VB.NET 87

Introduction to Programming 87

Data Types and Variables 88

Defining a Variable 88

Operators 91

Converting and Casting Data Types 93

Converting Data Types 93

Casting Data Types 96

Using Arrays and Collections 97

Using Arrays 97

Using Collections 99

Decision-Making Operations 101

Comparison Operators 102

Logical Operators 103

If Statement 104

Switch/Select Case Statement 106

Loops 106

For Loop 106

Foreach/For Each Loops 108

While Loop 109

Exiting Loops 110

Organizing Code 110

Methods: Functions and Subroutines 110

Writing Comments and Documentation 112

Object-Oriented Programming Basics 114

Important OO Terminology 115

Classes 115

Fields 116

Properties 117

Methods 120

Constructors 120

Inheritance 121

Events 123

Summary 125

CHAPTER 5: ASP.NET WEB FORM SERVER CONTROLS 129

Introduction to Server Controls 129

Defining Controls in Your Pages 130

Types of Controls 137

Standard Controls 138

HTML Controls 143

Data Controls 144

Validation Controls 144

Navigation Controls 145

Login Controls 145

AJAX Extensions 146

Other Control Sets 146

The ASP.NET State Engine 147

How the State Engine Works 148

Summary 157

CHAPTER 6: ASP.NET MVC HELPERS AND EXTENSIONS 161

Why MVC Has Fewer Controls Than Web Forms 162

A Different Approach 162

Razor 166

Controller 170

Routing 172

HTTP Verbs and Attributes 174

Form-Building Helpers 175

Form Extensions 175

Editor and EditorFor 177

Model Binding 177

Summary 194

CHAPTER 7: CREATING CONSISTENT-LOOKING WEBSITES 197

Consistent Page Layout with Master Pages 198

Creating and Using Master Pages in ASP.NET Web Forms 198

Creating a Content Page in ASP.NET Web Forms 208

Creating Layouts in ASP.NET MVC 212

Creating a Content View in ASP.NET MVC 215

Using a Centralized Base Page 219

Summary 225

CHAPTER 8: NAVIGATION 229

Different Ways to Move around Your Site 230

Understanding Absolute and Relative URLs 230

Understanding Default Documents 234

Friendly URLs 234

Using the ASP.NET Web Forms Navigation Controls 236

Using the Menu Control 240

Navigating in ASP.NET MVC 248

Routing 248

Default Configuration and Route 249

Creating a Navigational Structure 252

Programmatic Redirection 255

Programmatically Redirecting the Client to a Different Page 255

Server-Side Redirects 258

Practical Tips on Navigation 262

Summary 263

CHAPTER 9: DISPLAYING AND UPDATING DATA 267

Working with SQL Server Express 268

Installation 269

SQL Server Management Studio 276

Connecting in Visual Studio 282

Entity Framework Approach to Data Access 285

Data First 285

Code First 286

Selecting Data from the Database 295

Data Controls in Web Forms 297

Details View 297

Web Form GridView 303

Data Display in MVC 310

List Display in MVC 311

Details Views 314

Summary 318

CHAPTER 10: WORKING WITH DATA—ADVANCED TOPICS 323

Sorting and Pagination 324

Sorting and Pagination in Web Form Server Controls 324

Sorting and Pagination in MVC Lists 330

Updating and/or Inserting Data 339

A Non-Code First Approach to Database Access 347

Using SQL Queries and Stored Procedures 350

Caching 358

Different Ways to Cache Data in ASP.NET Applications 358

Common Pitfalls with Caching Data 362

Summary 363

CHAPTER 11: USER CONTROLS AND PARTIAL VIEWS 367

Introduction to User Controls 368

Creating User Controls 369

Adding User Controls 373

Sitewide Registration of a User Control 376

Managing the IDs of Any Controls 379

Adding Logic to Your User Controls 381

Using Partial Views 387

Adding a Partial View 389

Managing the Controller for a Partial View 393

Templates 400

Summary 408

CHAPTER 12: VALIDATING USER INPUT 413

Gathering Data from the User 414

Validating User Input in Web Forms 415

Understanding Request Validation 424

Validating User Input in MVC 426

Model Attribution 426

Client-Side Validation 434

Request Validation in ASP.NET MVC 443

Validation Tips 444

Summary 445

CHAPTER 13: ASP.NET AJAX 449

Introducing the Concept of AJAX 450

F12 Developer Tools 451

Using ASP.NET AJAX in Web Forms 457

The Initial AJAX Experience 457

Enhancing the AJAX Experience 466

Using AJAX in MVC 469

Using Web Services in AJAX Websites 483

jQuery in AJAX 489

Practical AJAX Tips 495

Summary 496

CHAPTER 14: jQUERY 499

An Introduction to jQuery 499

Early JavaScript 500

jQuery’s Role 500

Including the jQuery Library 503

Bundles 506

jQuery Syntax 512

jQuery Core 513

Working with the jQuery Utility Methods 514

Selecting Items Using jQuery 516

Modifying the DOM with jQuery 519

Changing Appearance with jQuery 519

Handling Events 523

Debugging jQuery 532

Practical Tips on jQuery 536

Summary 537

CHAPTER 15: SECURITY IN YOUR ASP.NET WEBSITE 541

Introducing Security 542

Identity: Who Are You? 542

Authentication: How Can Users Prove Who They Are? 542

Authorization: What Are You Allowed to Do? 543

Logging in with ASP.NET 543

Configuring Your Web Application for Security 547

Working with Users within Your Application 558

Roles 566

Configuring Your Application to Work with Roles 567

Programmatically Checking Roles 572

Practical Security Tips 576

Summary 576

CHAPTER 16: PERSONALIZING WEBSITES 581

Understanding the Profile 582

Creating the Profile 582

Using the Profile 590

Practical Personalization Tips 602

Summary 603

CHAPTER 17: EXCEPTION HANDLING, DEBUGGING, AND TRACING 605

Error Handling 606

Different Types of Errors 606

Syntax Errors 606

Logic Errors 607

Runtime Errors 609

Catching and Handling Exceptions 612

Global Error Handling and Custom Error Pages 621

Error Handling in a Controller 627

The Basics of Debugging 629

Tools Support for Debugging 629

Moving Around in Debugged Code 629

Debugging Windows 631

Other Windows 634

Debugging Client-Side Script 638

Tracing Your ASP.NET Web Pages 647

Adding Your Own Information to the Trace 650

Tracing and Performance 654

Logging 654

Downloading, Installing, and Configuring a Logger 655

Summary 658

CHAPTER 18: WORKING WITH SOURCE CONTROL 661

Introducing Team Foundation Services 661

Why Use Source Control 662

Setting Up a Visual Studio Online Account 662

Checking Code In and Out 669

Undoing Changes 670

Shelvesets 672

Getting a Specific Version from the Server 672

Seeing Changed Items in Solution Explorer 675

Looking at History and Comparing Versions 675

Labeling 676

Interacting with a Team 677

Changing Default Source Control Behavior in Visual Studio 677

Branching and Merging 678

Summary 681

CHAPTER 19: DEPLOYING YOUR WEBSITE 683

Preparing Your Website for Deployment 684

Avoiding Hard-Coded Settings 684

The Web.config File 685

Expression Syntax 685

The Web Configuration Manager Class 687

Preparing for Deployment 691

Microsoft Azure 691

Publishing Your Site 695

Introducing Web.config Transformations 706

Moving Data to a Remote Server 713

Smoke Testing Your Application 720

Going Forward 722

Summary 722

APPENDIX: ANSWERS TO EXERCISES 725

INDEX 735

Printer-Ready Version   Share This
With you wherever you go: pdf + ePub + kindle -- DRM-free