Beginning ASP.NET for Visual Studio 2015 - William Penberthy - E-Book

Beginning ASP.NET for Visual Studio 2015 E-Book

William Penberthy

0,0
28,99 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

The complete guide to the productivity and performance enhancements in ASP.NET Beginning ASP.NET for Visual Studio 2015 is your ultimate guide to the latest upgrade of this historically popular framework. Fully updated to align with the vNext release, this new edition walks you through the new tools and features that make your workflow smoother and your applications stronger. You'll get up to speed on the productivity and performance improvements, and learn how Microsoft has committed itself to more continuous innovation by increasing its release cadence for all products and services going forward. Coverage includes Async-aware debugging, ADO.NET idle connection resiliency, managed return value inspection, ASP.NET app suspension, on-demand large object heap compaction, multi-core JIT and more. The news of an off-cycle update to ASP.NET came as a surprise, but its announcement garnered cheers at the 2014 Microsoft BUILD conference. This guide shows you what all the fuss is about, and how Microsoft overhauled the latest ASP.NET release. * Get acquainted with the new developer productivity features * Master the new tools that build better applications * Discover what's new in Windows Store app development * Learn how Microsoft fixed the issues that kept you from v5 Over 38 million websites are currently using ASP.NET, and the new upgrade is already leading to increased adoption. Programmers need to master v6 to remain relevant as web development moves forward. Beginning ASP.NET for Visual Studio 2015 walks you through the details, and shows you what you need to know so you can get up and running quickly.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 1131

Veröffentlichungsjahr: 2016

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Cover

Introduction

Who This Book Is For

What This Book Covers

How This Book Is Structured

What You Need to Use This Book

Conventions

Source Code

Errata

p2p.wrox.com

Chapter 1: Getting Started with ASP.NET 6.0

Code Downloads for this Chapter:

An Introduction to ASP.NET vNext

Using Visual Studio 2015

The Sample Application

Summary

What You Learned in This Chapter

Chapter 2: Building an Initial ASP.NET Application

Code Downloads for this Chapter:

Creating Websites with Visual Studio 2015

Working with Files in Your Application

MVC and Web Form File Differences

Creating the Sample Application

Summary

What You Learned in This Chapter

Chapter 3: Designing Your Web Pages

Code Downloads for this Chapter:

HTML and CSS

More CSS

The Style Sheet

Applying Styles

Managing Styles

Summary

What You Learned in this Chapter

Chapter 4: Programming in C# and VB.NET

Code Downloads for this Chapter:

Introduction to Programming

Organizing Code

Object-Oriented Programming Basics

Important OO Terminology

Summary

What You Learned in This Chapter

Chapter 5: ASP.NET Web Form Server Controls

Code Downloads for this Chapter:

Introduction to Server Controls

Defining Controls in Your Pages

Types of Controls

The ASP.NET State Engine

How the State Engine Works

Summary

What You Learned in This Chapter

Chapter 6: ASP.NET MVC Helpers and Extensions

Code Downloads for this Chapter:

Why MVC Has Fewer Controls Than Web Forms

A Different Approach

Form-Building Helpers

Summary

What You Learned in This Chapter

Chapter 7: Creating Consistent-Looking Websites

Code Downloads for this Chapter:

Consistent Page Layout with Master Pages

Using a Centralized Base Page

Summary

What You Learned in This Chapter

Chapter 8: Navigation

Code Downloads for this Chapter:

Different Ways to Move around Your Site

Using the ASP.NET Web Forms Navigation Controls

Navigating in ASP.NET MVC

Practical Tips on Navigation

Summary

What You Learned in This Chapter

Chapter 9: Displaying and Updating Data

Code Downloads for this Chapter:

Working with SQL Server Express

Entity Framework Approach to Data Access

Data Controls in Web Forms

Data Display in MVC

Summary

What You Learned in This Chapter

Chapter 10: Working with Data—Advanced Topics

Code downloads for this chapter:

Sorting and Pagination

Updating and/or Inserting Data

A Non-Code First Approach to Database Access

Caching

Summary

What You Learned in This Chapter

Chapter 11: User Controls and Partial Views

Code Downloads for this Chapter:

Introduction to User Controls

Using Partial Views

Templates

Summary

What You Learned in This Chapter

Chapter 12: Validating User Input

Code Downloads for this Chapter:

Gathering Data from the User

Validating User Input in Web Forms

Validating User Input in MVC

Validation Tips

Summary

What You Learned in This Chapter

Chapter 13: ASP.NET AJAX

Code Downloads for this Chapter:

Introducing the Concept of AJAX

Using Web Services in AJAX Websites

JQuery in AJAX

Practical AJAX Tips

Summary

What You Learned in This Chapter

Chapter 14: jQuery

Code Downloads for this Chapter:

An Introduction to JQuery

JQuery Syntax

Modifying the DOM with JQuery

Debugging JQuery

Practical Tips on JQuery

Summary

What You Learned in This Chapter

Chapter 15: Security in Your ASP.NET Website

Code Downloads for this Chapter:

Introducing Security

Roles

Practical Security Tips

Summary

What You Learned in This Chapter

Chapter 16: Personalizing Websites

Code Downloads for this Chapter:

Understanding the Profile

Practical Personalization Tips

Summary

What You Learned in This Chapter

Chapter 17: Exception Handling, Debugging, and Tracing

Code Downloads for this Chapter:

Error Handling

The Basics of Debugging

Tracing Your ASP.NET Web Pages

Logging

Summary

What You Learned in This Chapter

Chapter 18: Working with Source Control

Code Downloads for this Chapter:

Introducing Team Foundation Services

Branching and Merging

Summary

What You Learned in This Chapter

Chapter 19: Deploying Your Website

Code Downloads for this Chapter:

Preparing Your Website for Deployment

Preparing for Deployment

Publishing Your Site

Smoke Testing Your Application

Going Forward

Summary

What You Learned in This Chapter

Answers to Exercises

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

Chapter 7

Chapter 8

Chapter 9

Chapter 10

Chapter 11

Chapter 12

Chapter 13

Chapter 14

Chapter 15

Chapter 16

Chapter 17

Chapter 18

Chapter 19

End User License Agreement

Pages

xxi

xxii

xxiii

xxiv

xxv

xxvi

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

439

440

441

442

443

444

445

446

447

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

635

636

637

638

639

640

641

642

643

644

645

646

647

648

649

650

651

652

653

654

655

656

657

658

659

660

661

662

663

664

665

666

667

668

669

670

671

672

673

674

675

676

677

678

679

680

681

682

683

684

685

686

687

688

689

690

691

692

693

694

695

696

697

698

699

700

701

702

703

704

705

706

707

708

709

710

711

712

713

714

715

716

717

718

719

720

720

721

722

723

725

726

727

728

729

730

731

732

733

734

Guide

Cover

Table of Contents

Begin Reading

List of Illustrations

Chapter 1: Getting Started with ASP.NET 6.0

Figure 1.1 Request response

Figure 1.2 HTML rendered in the browser

Figure 1.3 Model-View-Controller (MVC) design

Figure 1.4 Different Approaches Between MVC and Web Forms

Figure 1.5 Visual Studio site to download Community Edition

Figure 1.6 Installation screen for Community Edition

Figure 1.7 Select items to install

Figure 1.8 Setup Completed window

Figure 1.9 Login screen in Visual Studio

Figure 1.10 Initial configuration of Visual Studio

Figure 1.11 Start Page for Visual Studio

Chapter 2: Building an Initial ASP.NET Application

Figure 2.1 Creating a project or web site

Figure 2.2 Options when creating a new web site

Figure 2.3 Creating a new project in Visual Studio

Figure 2.4 Selecting the appropriate ASP.NET template

Figure 2.5 Authentication options for a new project

Figure 2.6 Adding directories and unit tests

Figure 2.7 Creating a project using the Empty template

Figure 2.8 References created for an empty template

Figure 2.9 Running a newly created default Web Forms project

Figure 2.10 API Help page in a Web API project

Figure 2.11 Installed folders with ASP.NET MVC

Figure 2.12 Details under the Controllers and Views folders

Figure 2.13 Relationship between View files and Controller files in an ASP.NET MVC application

Figure 2.14 Account management functionality in Web Forms

Figure 2.15 Creating your initial project

Chapter 3: Designing Your Web Pages

Figure 3.1 HTML without any CSS styling

Figure 3.2 HTML with some simple styles added

Figure 3.3 New ASP.NET Web Form file

Figure 3.4 Selecting Split mode displays both design and source code information.

Figure 3.5 Code window with display of text

Figure 3.6 Design mode view of style and HTML content

Figure 3.7 Inheritance in CSS

Figure 3.8 Padding, border, and margin

Figure 3.9 Rendered HTML with padding, margin, and width

Figure 3.10 Adding a user style sheet to your browser

Figure 3.11 Adding a new style sheet

Figure 3.12 Page after removing style

Figure 3.13 Viewing the file in Design mode

Figure 3.14 Formatting toolbar

Figure 3.15 New Style dialog

Figure 3.16 Menu options available in Design mode

Figure 3.17 Screen changes after selecting both ruler and grid

Figure 3.18 Design mode with all visual aids enabled

Figure 3.19 Displaying Tag Marks in Design mode

Figure 3.20 CSS Properties window

Figure 3.21 Simple design for sample application home page

Figure 3.22 Simple design for the list of product items

Figure 3.23 Initial styling approach to the home page

Figure 3.24 Content in Design mode

Figure 3.25 Setting body style

Chapter 4: Programming in C# and VB.NET

Figure 4.1 Demonstration of XML comments in IntelliSense

Figure 4.2 Inheritance displayed in IntelliSense

Chapter 5: ASP.NET Web Form Server Controls

Figure 5.1 Toolbox menu in Visual Studio

Figure 5.2 IntelliSense support for manually entering server controls

Figure 5.3

Figure 5.4 IntelliSense for help selecting the OnClick Event

Figure 5.5 IntelliSense help for creating an event handler

Figure 5.6 Initial display of HTML

Figure 5.7 Setting breakpoints in your code

Figure 5.8 HTML created when using server controls

Figure 5.9 Standard controls list from the Toolbox

Figure 5.10 Data controls list from the Toolbox

Figure 5.11

Figure 5.12

Figure 5.13

Figure 5.14 AJAX extensions

Figure 5.15 Other ASP.NET controls

Figure 5.16 Create a report UI.

Figure 5.17 Changed textbox value is returned.

Figure 5.18 Web Form with Master Page

Figure 5.19 Selecting a Master Page

Figure 5.20 Newly created form fields

Figure 5.21 Poorly formatted form

Figure 5.22 Code-behind in Debug mode

Chapter 6: ASP.NET MVC Helpers and Extensions

Figure 6.1 Workflow for a model being passed to a view

Figure 6.2 Simple model displayed in your MVC view

Figure 6.3 Output when including the @ character

Figure 6.4 Output of a @foreach loop writing the display

Figure 6.5 The RouteConfig.cs file in the App_Start directory

Figure 6.6 Error when Id is not included in the URL

Figure 6.7 Creating the Model class

Figure 6.8 Creating the Controller class

Figure 6.9 Naming the Controller class

Figure 6.10 Views folder created when adding the controller

Figure 6.11 Dialog to add a view

Figure 6.12 Browser display of the Index field

Figure 6.13 Initial data-entry form

Figure 6.14 Edited data-entry form

Figure 6.15 Create a breakpoint in a method

Figure 6.16 404 error when running the Manage view

Figure 6.17 Displaying the Edit screen

Chapter 7: Creating Consistent-Looking Websites

Figure 7.1 Web page within a template

Figure 7.2 Master page with multiple content sections

Figure 7.3 Nested master pages

Figure 7.4 Nested master pages

Figure 7.5 Adding a new master page

Figure 7.6 Unstyled master page in Design mode

Figure 7.7 Styled master page in Design mode

Figure 7.8 Location of linked master page in the project

Figure 7.9 Error caused by having text outside content control

Figure 7.10 Add New Item dialog

Figure 7.11 Selecting the master page

Figure 7.12 Form in the new master page

Figure 7.13 Relationship between content page and Render command

Figure 7.14 Add View dialog

Figure 7.15 Initial dialog when creating a brand-new view

Figure 7.16 Addition of a base class

Figure 7.17 Creating a new base class

Figure 7.18 Inheriting the Page class

Figure 7.19 Overriding the OnLoad method

Figure 7.20 Adding values to the page definition

Figure 7.21 Adding validation that keywords and description are set

Figure 7.22 Error thrown when keywords and description are not set

Figure 7.23 Error thrown when the page does not extend System.Web.UI.Page

Chapter 8: Navigation

Figure 8.1 Relative URLs

Figure 8.2 IIS management console with RentMyWrox as a virtual application

Figure 8.3 Initial RouteConfig.cs file

Figure 8.4 Default display of TreeView and Menu controls

Figure 8.5 Creating the Web.sitemap file

Figure 8.6 Error displayed when multiple siteMapNodes appear within the sitemap element

Figure 8.7 Configuring the Menu control in Design mode

Figure 8.8 Selecting data source for the Menu control

Figure 8.9 Menu display after turning off the starting node

Figure 8.10 Rendered example of the menu

Figure 8.11 HTML created by the Menu control

Figure 8.12 Page with styled menu

Figure 8.13 Routing process

Figure 8.14 The initial RouteConfig.cs file

Figure 8.15 Ambiguous action exception

Figure 8.16 Add View dialog

Figure 8.17 Client-side redirection flow

Figure 8.18 Creating a WeeklySpecial page

Figure 8.19 Code for the redirect of the WeeklySpecial

Figure 8.20 Exception using Server.Transfer

Figure 8.21 Server.Transfer to .aspx page

Figure 8.22 Server transfer of page flow

Chapter 9: Displaying and Updating Data

Figure 9.1 User Account Control dialog

Figure 9.2 Selecting extract directory

Figure 9.3 SQL Server Installation Center

Figure 9.4 SQL Server Installation Center - Tools

Figure 9.5 Setup Support Rules

Figure 9.6 License Terms dialog

Figure 9.7 Microsoft Update dialog

Figure 9.8 Feature Selection dialog

Figure 9.9 Instance Configuration dialog

Figure 9.10 Server Configuration dialog

Figure 9.11 Database Engine Configuration dialog

Figure 9.12 Windows Services installed as part of SQL Server

Figure 9.13 SQL Server shortcut

Figure 9.14 Connect to Server dialog in SQL Server Management Studio

Figure 9.15 Object Explorer, showing connected server

Figure 9.16 New Database dialog

Figure 9.17 Expanded database

Figure 9.18 Window for creating a table

Figure 9.19 Filled-out table information

Figure 9.20 Editable window

Figure 9.21 Object Explorer, showing the active server

Figure 9.22 Object Explorer, showing the stopped server

Figure 9.23 SQL Server Object Explorer

Figure 9.24 SQL Server Object Explorer Connect to Server dialog

Figure 9.25 SQL Server Object Explorer Browse for Servers dialog

Figure 9.26 New database connection in SQL Server Object Explorer

Figure 9.27 Working with the data in SQL Server Object Explorer

Figure 9.28 Preview Database Updates in SQL Server Object Explorer

Figure 9.29 Adding the database context file

Figure 9.30 Entity Data Model Wizard

Figure 9.31 Basic DbContext file

Figure 9.32 SQL Server Object Explorer with server name

Figure 9.33 Web.ConFigure file connection strings

Figure 9.34 Hobby class

Figure 9.35 UserDemographics class

Figure 9.36 Updated data context class

Figure 9.37 Newly created database tables

Figure 9.38 Visual Designer approach

Figure 9.39 New DetailsView control

Figure 9.40 DetailsView control with methods assigned

Figure 9.41 DetailsView rendered in the browser

Figure 9.42 Debug values before running the SaveChanges method

Figure 9.43 Debug values after running the SaveChanges method

Figure 9.44 Error displayed when trying to update the database

Figure 9.45 Package Manager Console

Figure 9.46 Server Manager and Design mode

Figure 9.47 Screen after dropping table into page design

Figure 9.48 Displaying the GridView

Figure 9.49 Migrations directory after enabling and running code first migrations

Figure 9.50 Adding the view file

Figure 9.51 List of items on front page

Figure 9.52 Details page for an item

Figure 9.53 Details page when an item does not exist

Figure 9.54 Details page when an item is not available

Chapter 10: Working with Data—Advanced Topics

Figure 10.1 GridView with pagination and sorting

Figure 10.2 GridView with pagination turned off

Figure 10.3 New Index method signature

Figure 10.4 New Index method

Figure 10.5 New view code

Figure 10.6 New view pagination code

Figure 10.7 Running the paginated list

Figure 10.8 Initial change to the Manage view

Figure 10.9 Redoing the Manage view

Figure 10.10 New property in the code-behind

Figure 10.11 Add New Item link in the Item List page

Figure 10.12 HTML created to support the hobby selection

Figure 10.13 New method in UserDemographicsController

Figure 10.14 Add View dialog

Figure 10.15 New view code

Figure 10.16 Running HobbyReport

Figure 10.17 Setting up the new stored procedure

Figure 10.18 Displaying the residency report

Figure 10.19 Directory of cached items

Figure 10.20 Output caching on the Details action

Figure 10.21 Breakpoint in the Details action

Chapter 11: User Controls and Partial Views

Figure 11.1 Creating a Web Forms user control

Figure 11.2 Editing the markup of your control

Figure 11.3 Adding the Notification model

Figure 11.4 Editing the code-behind of your control

Figure 11.5 Database view of the Notifications table created by the application

Figure 11.6 Page after registering your user control

Figure 11.7 Empty Notifications table

Figure 11.8 Entering data into the Notifications table

Figure 11.9 Default page showing the user control

Figure 11.10 Default Web.ConFigure file

Figure 11.11 Web.conFigure after registering your user control

Figure 11.12 Adding the user control

Figure 11.13 ManageItem page after the control is successfully added

Figure 11.14 Enum values shown in IntelliSense

Figure 11.15 Validation when using an incorrect type

Figure 11.16 Error when using an incorrect type in a user control

Figure 11.17 Adding in user control with additional properties

Figure 11.18 Page life cycle with page and hosted control

Figure 11.19 Adding a partial view

Figure 11.20 Removing scaffolded information

Figure 11.21 Finished partial view

Figure 11.22 Finished partial view

Figure 11.23 Partial view shown in the UI

Figure 11.24 Scaffolding for adding a new controller

Figure 11.25 Empty controller

Figure 11.26 Notifications controller with actions

Figure 11.27 Updated layout view

Figure 11.28 SQL Table view after adding new item

Figure 11.29 New notification displayed in the UI from a partial view

Figure 11.30 Initial screen showing default DateTime management

Figure 11.31 Views directory after Templates directories are added

Figure 11.32 Adding DateTime Display template

Figure 11.33 Viewing the DisplayFor template

Figure 11.34 Content of the project's Scripts directory

Figure 11.35 Selecting jQuery package in Package Manager

Figure 11.36 Installing the jQuery UI package

Figure 11.37 Updating the layout page

Figure 11.38 Finished Editor template

Chapter 12: Validating User Input

Figure 12.1 Validation controls in Visual Studio Toolbox

Figure 12.2 Adding the ValidationSummary control

Figure 12.3 Adding some validation controls

Figure 12.4 Additional validation controls

Figure 12.5 Validation displayed

Figure 12.6 Validation displayed

Figure 12.7 Error thrown during request validation

Figure 12.8 Attributed property

Figure 12.9 Fully attributed class

Figure 12.10 Package Manager Console

Figure 12.11 Error caused by StringLength on the integer property

Figure 12.12 Properties showing 15-character column

Figure 12.13 Error when trying to save invalid data in the controller

Figure 12.14 Nuget Package Manager Window

Figure 12.15 Scripts directory after adding new packages

Figure 12.16 Content of the BundleConFigure file

Figure 12.17 New ValidationSummary configuration

Figure 12.18 Updated code block

Figure 12.19 Changed view page

Figure 12.20 Validation displayed in the browser

Chapter 13: ASP.NET AJAX

Figure 13.1 Classic and asynchronous models

Figure 13.2 Google Chrome Developer tools

Figure 13.3 Mozilla Firefox Developer tools

Figure 13.4 Opening the F12 Developer Tools through the menu

Figure 13.5 Dom Explorer and the Styles tab

Figure 13.6 Network tab

Figure 13.7 Network tab recording requests

Figure 13.8 DOM Explorer tab showing Styles

Figure 13.9 DOM Explorer tab showing the Computed tab

Figure 13.10 DOM Explorer tab showing the Layout tab

Figure 13.11 Network tab showing the Request headers

Figure 13.12 AJAX controls available in Visual Studio

Figure 13.13 UpdatePanel and ScriptManager relationship

Figure 13.14 Updated notifications control markup page

Figure 13.15 Rendered Notifications control

Figure 13.16 F12 Network tab without the UpdatePanel

Figure 13.17 F12 Response body without the UpdatePanel

Figure 13.18 F12 Network tab with the UpdatePanel

Figure 13.19 F12 Response body with UpdatePanel

Figure 13.20 Difference between displayed item and view source output

Figure 13.21 Request body differences

Figure 13.22 Updated DisplayInformation method

Figure 13.23 Updated control to include UpdateProgress method

Figure 13.24 Update Progress message visible

Figure 13.25 Updated context file

Figure 13.26 Configuration for a new partial view

Figure 13.27 New partial view content

Figure 13.28 New Controller with private variable

Figure 13.29 Search results in NuGet Package Manager

Figure 13.30 Screen with empty shopping cart

Figure 13.31 Screen with updated shopping cart

Figure 13.32 F12 Developer Tool showing the response body

Figure 13.33 Downloading the StoreOpen.json file

Figure 13.34 Addition of area to display store hours message

Figure 13.35 JavaScript added to the page

Figure 13.36 Running the new changes

Chapter 14: jQuery

Figure 14.1 Installed jQuery packages

Figure 14.2 Bottom of the _MVCLayout.cshtml page

Figure 14.3 Adding a new JavaScript file

Figure 14.4 After moving some JavaScript from the layout file

Figure 14.5 The updated layout file

Figure 14.6 The newly created source

Figure 14.7 Web.conFigure file content

Figure 14.8 Debugging Not Enabled dialog

Figure 14.9 Source code with bundling

Figure 14.10 Bundled JavaScript output

Figure 14.11 Updated Ajax.ActionLink

Figure 14.12 Updating the Index page

Figure 14.13 Enabling debugging in Internet Explorer

Figure 14.14 Adding breakpoints in jQuery/JavaScript

Figure 14.15 Hitting a breakpoint in JavaScript

Figure 14.16 Setting a breakpoint in the browser tools

Figure 14.17 Hitting a breakpoint in the browser tools

Figure 14.18 Error in browser when trying to debug

Chapter 15: Security in Your ASP.NET Website

Figure 15.1 Startup_Auth page

Figure 15.2 Interaction with third-party authorizer

Figure 15.3 Current Web.ConFigure file

Figure 15.4 Updated head section of the Master page

Figure 15.5 Post-deleted section of the Master page

Figure 15.6 New Shopping cart summary partial view

Figure 15.7 Initial tables in database

Figure 15.8 Login page

Figure 15.9 Register page

Figure 15.10 Validation failure page

Figure 15.11 Empty checkout page

Figure 15.12 Updated database

Figure 15.13 AspNetUsers data

Figure 15.14 UserHelper.cs

Figure 15.15 UserHelper.cs

Figure 15.16 Default page in the Admin directory

Figure 15.17 Creating a web.conFigure file for the Admin directory

Figure 15.18 Adding a role to the database

Figure 15.19 Assigning a role to a user in the database

Figure 15.20 ApplicationUser with roles collection populated

Figure 15.21 Updating the menu in the _MVCLayout.cshtml file

Figure 15.22 Home page with Admin menu

Chapter 16: Personalizing Websites

Figure 16.1 New class for addresses

Figure 16.2 Additional user properties

Figure 16.3 Initial migration script

Figure 16.4 New migrations directory

Figure 16.5 ApplicationDbMigration migration file

Figure 16.6 Failed database update

Figure 16.7

Figure 16.8 Updated GetShoppingCartSummary method

Figure 16.9 Updated registration page

Figure 16.10 Updated AddToCart method

Figure 16.11 Adding a new view

Figure 16.12 Updated layout page

Figure 16.13 Home page with recent items displayed at the bottom

Figure 16.14 Shopping cart area displaying name

Chapter 17: Exception Handling, Debugging, and Tracing

Figure 17.1 Error List in Visual Studio

Figure 17.2 ASP.NET Web Forms parser error

Figure 17.3 ASP.NET Web Forms server error with VS

Figure 17.4 This MVC view has syntax error yet compiles.

Figure 17.5 Runtime error caused by MVC view syntax error

Figure 17.6 Application_Error event handler

Figure 17.7 Master page selected

Figure 17.8 Error404 content

Figure 17.9 Custom error configuration in the web.conFigure file

Figure 17.10 Displaying the Error404 page

Figure 17.11 Debugging toolbar

Figure 17.12 Debugging toolbar

Figure 17.13 Watch windows

Figure 17.14 Working Watch window

Figure 17.15 Working Autos window

Figure 17.16 Expanded this variable in the Autos window

Figure 17.17 Working Locals window

Figure 17.18 Working Breakpoint window

Figure 17.19 Window for selecting a condition

Figure 17.20 Using the Call Stack window

Figure 17.21 Using the Immediate window

Figure 17.22 _MVCLayout content

Figure 17.23 Addition of checks

Figure 17.24 Error thrown when checking out

Figure 17.25 Locals window when stopped by error

Figure 17.26 Successful Checkout window

Figure 17.27 Autos window

Figure 17.28 Autos window with details displayed

Figure 17.29 Completed order detail screen

Figure 17.30 Trace listing page

Figure 17.31 Trace details page

Figure 17.32 Web.conFigure file after enabling trace

Figure 17.33 Web.conFigure file after enabling listeners

Figure 17.34 Trace details page with error

Figure 17.35

Figure 17.36

Chapter 18: Working with Source Control

Figure 18.1 Visual Studio Online initial login message

Figure 18.2 Creating a Visual Studio Online account

Figure 18.3 Creating a project in Visual Studio Online

Figure 18.4 Team Explorer - Connect dialog

Figure 18.5 Connect to Team Foundation Server dialog

Figure 18.6 Adding a Team Foundation Server

Figure 18.7 Team Foundation Server list

Figure 18.8 Selecting projects to use as a repository

Figure 18.9 Team Explorer pane before workspace mapping

Figure 18.10 Configuring the workspace

Figure 18.11 Adding your solution to Source Control

Figure 18.12 Source Control Explorer window after adding the solution

Figure 18.13 Pending changes before a check-in

Figure 18.14 Team Explorer context menu

Figure 18.15 Undo Pending Changes confirmation

Figure 18.16 Final confirmation dialog before undoing changes

Figure 18.17 Creating a shelveset

Figure 18.18 Source Code menu from Solution Explorer

Figure 18.19 Get dialog, for retrieving a specific version

Figure 18.20 Conflict found

Figure 18.21 Finding a shelveset

Figure 18.22 Unshelving a shelveset

Figure 18.23 Visualizing file status in Solution Explorer

Figure 18.24 History window for a file

Figure 18.25 Comparing two versions of a file

Figure 18.26 Creating and applying a label

Figure 18.27 Changing default settings when working with a file in source control

Figure 18.28 Branch dialog

Figure 18.29 Source Control Explorer after branching

Figure 18.30 Merging branches

Chapter 19: Deploying Your Website

Figure 19.1 Properties window

Figure 19.2 Expressions dialog

Figure 19.3 AppSettings in the Expressions dialog

Figure 19.4 Updated StoreOpenController

Figure 19.5 Updated ItemList markup file

Figure 19.6 Azure home page

Figure 19.7 Azure free trial page

Figure 19.8 Azure sign-up page

Figure 19.9 Subscription is ready page

Figure 19.10 Azure tour page

Figure 19.11 Azure dashboard page

Figure 19.12 Publish Web dialog

Figure 19.13 Select Existing Web App dialog

Figure 19.14 Create Web App on Microsoft Azure dialog

Figure 19.15 Completed Create Web App on Microsoft Azure dialog

Figure 19.16 Creating the new Web App

Figure 19.17 Creation screen with connection validated

Figure 19.18 Web Apps listing in Azure

Figure 19.19 SQL Database listing in Azure

Figure 19.20 Creating a SQL Database

Figure 19.21 Create Server dialog in Azure

Figure 19.22 Database being created in Azure

Figure 19.23 Adding a custom publish profile

Figure 19.24 Configuration screen for a custom profile

Figure 19.25 Selecting a target location for a custom profile

Figure 19.26 Published files

Figure 19.27 Web App .pubxml file

Figure 19.28 Multiple configuration files

Figure 19.29 Publish-Profiles directory

Figure 19.30 New PublishProfiles-based configuration

Figure 19.31 Previewing the transformation

Figure 19.32 Transformed store hours change

Figure 19.33 Transformed store hours change

Figure 19.34 SQL Database details screen

Figure 19.35 Connection Strings dialog

Figure 19.36 Deployed, but empty, web server

Figure 19.37 Confirmation screen to add IP address

Figure 19.38 Generate Scripts menu

Figure 19.39 Generate Scripts dialog

Figure 19.40 Generate Scripts menu

Figure 19.41 Specifying script output

Figure 19.42 Advanced Scripting Options

Figure 19.43 Finished creating items

Figure 19.44 Connecting to Azure SQL

Figure 19.45 Selecting the appropriate database

Figure 19.46 Output of database-seeding

Figure 19.47 Populated online application

Figure 19.48 Completed smoke test order

List of Tables

Chapter 1: Getting Started with ASP.NET 6.0

Table 1.1 Most Frequently Used HTTP Verbs

Table 1.2 Commonly Used HTML Elements

Table 1.3 ASP.NET Page Lifecycle Stages

Table 1.4 Lifecycle Events for ASP.NET Pages

Chapter 2: Building an Initial ASP.NET Application

Table 2.1 ASP.NET MVC File Types

Table 2.2 ASP.NET General Folders

Table 2.3 File Types of an ASP.NET Web Forms Application

Chapter 3: Designing Your Web Pages

Table 3.1 CSS Properties

Table 3.2 Visual Aids

Chapter 4: Programming in C# and VB.NET

Table 4.1 Common Data Types Available in C# and VB.NET

Table 4.2 Arithmetic Operators

Table 4.3 Convert.ToDouble() Examples

Table 4.4 Using a List

Table 4.5 Comparison Operators

Table 4.6 Logical Operators

Chapter 5: ASP.NET Web Form Server Controls

Table 5.1 Common Standard Server Controls

Table 5.2 Common Standard Control General Attributes

Table 5.3 Standard Server Control Special Attributes

Chapter 6: ASP.NET MVC Helpers and Extensions

Table 6.1 Display Extension Methods

Table 6.2 Type-Safe Extensions

Table 6.3 Scaffold-Created Actions in a New Controller

Chapter 8: Navigation

Table 8.1 Attributes of a Menu Control

Chapter 9: Displaying and Updating Data

Table 9.1 Minimum and Maximum System Settings

Table 9.2 SQL Server Management Studio Folders

Table 9.3 Database Management Feature Availability

Table 9.4 Parts of a Connection String

Table 9.5 Selecting and Sorting Data

Table 9.6 Data Control Field Definitions

Table 9.7 Data-Binding Methods

Chapter 10: Working with Data—Advanced Topics

Table 10.1 GridView Pagination and Sorting Attributes

Table 10.2 Displaying Links by Page

Table 10.3 Methods Available on DbContext.Database

Table 10.4 Caching Locations

Chapter 11: User Controls and Partial Views

Table 11.1 Notification Properties

Table 11.2 Attributes for User Control Registration

Table 11.3 ClientIdMode Values

Table 11.4 Method Signatures for Including Partial Views

Table 11.5 DateTime Formatting

Chapter 12: Validating User Input

Table 12.1 Validation Server Controls

Table 12.2 Validator Properties

Table 12.3 Data Attributes Used in Validation

Chapter 13: ASP.NET AJAX

Table 13.1 Common UpdatePanel Properties

Table 13.2 Potential Items for Populating an Ajax.ActionLink

Chapter 14: jQuery

Table 14.1 Additional jQuery Modules

Table 14.2 Useful jQuery Utility Methods

Table 14.3 jQuery Selectors

Table 14.4 CSS Methods in jQuery

Table 14.5 Animation and Other Effects in jQuery

Table 14.6 Common JavaScript Events

Chapter 15: Security in Your ASP.NET Website

Table 15.1 SignInStatus Values

Table 15.2 IdentityUser Properties

Table 15.3 Password Validation Configuration Properties

Chapter 16: Personalizing Websites

Table 16.1 Database Migration Configuration Properties

Chapter 17: Exception Handling, Debugging, and Tracing

Table 17.1 Common Exceptions

Table 17.2 Properties on the Exception Class

Table 17.3 HandleError Properties

Table 17.4 Keystrokes That Support Debugging

Table 17.5 Sections Available in Trace Output

Table 17.6 Trace Configuration Attributes

Table 17.7 Trace Methods

Table 17.8 nLog Logging Levels

Chapter 19: Deploying Your Website

Table 19.1 Transformation Items

Introduction

It was estimated in June 2015 that 45 percent of the world's population has accessed the Internet. That's over 3 billion users, and the number is growing every day. This is a vast, connected market that can reach any content you decide to make available, be it a simple web page or a complex web application.

There are a lot of ways that you can make a simple web page available online. There are a lot fewer approaches when you are trying to build a web application. One of these web application technologies is ASP.NET from Microsoft.

ASP.NET is a framework that supports the building of robust and performant web applications. Think of it as the structural support for a car. You can add a couple of different body designs on top of this structure: ASP.NET Web Forms and ASP.NET MVC. These two approaches both rest on ASP.NET and depend on common functionality that is made available through ASP.NET.

Visual Studio 2015 is the primary tool used when creating and maintaining ASP.NET web applications. It will help you easily work with every aspect of your web application, from the “look and feel” all the way through to deployment of your application—and skipping none of the steps in between. In addition, because Microsoft is committed to supporting ASP.NET developers, it is available in a fully functional free version!

This book is an exploration of both ASP.NET Web Forms and MVC. As part of this exploration you will become familiar with all of the various components of a functional web application, creating a sample application as you go through the different parts of the development process. You will learn how the two frameworks do things, with some approaches being very similar while others are completely different. No matter the style of approach, however, it is always clear that they both rest on the same framework.

Who This Book Is For

This book is designed for anyone who wants to build robust, performant, and scalable web applications. Although the development tools run in Microsoft Windows, you are free to deploy the application onto virtually any current operating system; therefore, even organizations that don't have Microsoft servers have the capability to now run ASP.NET web applications.

If you are new to software development you should have no problem following along, as the book has been structured with you in mind. Those of you who are experienced developers but new to web development will also find many different areas of interest and use, especially if C# is not your current programming language.

Lastly, experienced ASP.NET developers should also find many topics of interest, especially if your experience is mainly related to either Web Forms or MVC, but not both. This book will give you experience in both approaches as well as demonstrate how to integrate the two approaches into a single application.

What This Book Covers

This book teaches you how to build a fully functional web application. You will have the opportunity to build a complete site using both ASP.NET MVC and ASP.NET Web Forms approaches so that you can develop an understanding of, and build a comfort level with, the complete ASP.NET set of functionality. Each chapter takes you a step further along the development process:

Chapter 1: Getting Started with ASP.NET 6.0

—You will get an introduction to ASP.NET as a general framework and specifically with Web Forms and MVC. You will also download and install Visual Studio 2015.

Chapter 2: Building an Initial ASP.NET Application

—In this chapter you create the initial project, including configuring it to support both Web Forms and MVC.

Chapter 3: Designing Your Web Pages

—This chapter introduces you to HTML and CSS so that you can build attractive and understandable web sites.

Chapter 4: Programming in C# and VB.NET

—ASP.NET is a developmental framework with which you can use different programming languages, including C# and VB.NET. This chapter provides an introduction to using them.

Chapter 5: ASP.NET Web Form Server Controls

—ASP.NET Web Forms offers many different forms of built-in functionality that it provides as server controls. These controls enable you to create complex and feature-rich web sites with very little code. This chapter covers the most common controls.

Chapter 6: ASP.NET MVC Helpers and Extensions

—Whereas ASP.NET Web Forms have server controls to provide features, ASP.NET MVC offers a different type of support through the use of helpers and extensions. This chapter describes that different support.

Chapter 7: Creating Consistent-Looking Websites

—You will learn how ASP.NET enables you to use master pages and layout pages to create a consistent look and feel throughout your web application.

Chapter 8: Navigation

—In this chapter you learn the different ways to create menus and other navigation structures. You also look at the different types of links that you can build in both Web Forms and MVC.

Chapter 9: Displaying and Updating Data

—When you want to use a database with ASP.NET, there are no better options than SQL Server. In this chapter, you install SQL Server, create your initial database schema, and incorporate the creation and display of data into your application.

Chapter 10: Working with Data

Advanced Topics

—Advanced topics include pagination, sorting, and using advanced database items such as stored procedures to retrieve special sets of information from the database. You will also learn how you can speed up responsiveness by storing data in various places.

Chapter 11: User Controls and Partial Views

—ASP.NET offers server controls and helpers to provide built-in functionality. Learn how to create your own items to provide common functionality across multiple pages.

Chapter 12: Validating User Input

—A large part of your site's functionality is defined by the data that users input into your application. This chapter shows you how to accept, validate, and process user input using tools for both Web Forms and MVC.

Chapter 13: ASP.NET AJAX

—AJAX is a technology that enables you to update parts of your page without making a full-page call to the server. Learn how to do this for both Web Forms and MVC.

Chapter 14: jQuery

—Everything covered up until this point has been based on doing work on the server. In this chapter you are introduced to using jQuery for work on the client, without having to call back to the server.

Chapter 15: Security in Your ASP.NET Website

—This chapter adds the concept of a user, demonstrating how you can identify your visitors by requiring them to log in to your application.

Chapter 16: Personalizing Websites

—Here you will learn how to customize the user information you are using to get the information needed to ensure that users feel welcome at your site. Capturing information about the user's visit also helps you better understand what they want when they visit your site.

Chapter 17: Exception Handling, Debugging, and Tracing

—Unfortunately, it's very difficult to write code that is totally problem-free. Learn how to manage these problems, including finding and fixing them as well as ensuring that when they happen, users are given the relevant information as to why their actions were not successful.

Chapter 18: Working with Source Control

—Working within a team is an important aspect of being a professional developer. Source control provides a way for you to share code among users. It also manages backing up your source code with saved versions.

Chapter 19: Deploying Your Website

—After completing all the work to build your application, the last step is getting out onto the web where your users can visit it!

How This Book Is Structured

The primary instructional approach in this book is a set of detailed hands-on steps that walk you through the process of building a complete application. These “Try It Out” activities, which demonstrate whatever topic is under discussion, are followed by a “How It Works” section that explains what each step accomplishes. Each of the “Try It Out” sections builds on what was done previously, so they should be followed sequentially.

Exercise questions at the end of the chapter enable you to test your understanding of the material, and answers are available in the appendix. Some questions are specific, others more general. Together they are designed to help reinforce the information presented in the chapter.

A lot of information is presented in this book; it covers two technological approaches that sometimes seem completely different. Additional sources of information are included in the chapters if you want more detailed information about a particular approach or product.

What You Need to Use This Book

In order to follow along with the chapter and its hands-on activities, you will need the following:

Windows 7, 8, or 10 or Windows Server 2008 or 2012

The minimum requirements for Visual Studio 2015, including RAM and hard drive space

Conventions

To help you get the most from the text and keep track of what's happening, we've used a number of conventions throughout the book.

TRY IT OUT: TRY IT OUT

This is a hands-on exercise you should work through, following the text in the book.

They consist of a set of steps.

Each step has a number.

Follow the steps with your copy of the database.

How It Works

This section explains in detail the code from each “Try It Out” activity.

WARNING

Boxes like this one hold important, not-to-be forgotten information that is directly relevant to the surrounding text.

NOTE

These are tips, hints, tricks, or asides to the current discussion, offset and placed in italics like this.

As for styles in the text:

We

highlight

new terms and important words when we introduce them.

We show keyboard strokes like this: Ctrl+A.

We show filenames, URLs, and code within the text like so:

persistence.properties

.

We present code in two different ways:

We use a monofont type with no highlighting for most code examples.

We use bold to emphasize code that's particularly important in the present context.

Source Code

As you work through the examples in this book, you may choose either to type in all the code manually or to use the source code files that accompany the book. All the source code used in this book is available for download at http://www.wrox.com/go/beginningaspnetforvisualstudio. You will find the code snippets from the source code are accompanied by a download icon and note indicating the name of the program so you know it's available for download and can easily locate it in the download file. Once at the site, simply locate the book's title (either by using the Search box or by using one of the title lists) and click the Download Code link on the book's detail page to obtain all the source code for the book.

NOTE

Because many books have similar titles, you may find it easiest to search by ISBN; this book's ISBN is 978-1-119-07742-8.

After downloading the code, just decompress it with your favorite compression tool. Alternately, you can go to the main Wrox code download page at http://www.wrox.com/dynamic/books/download.aspx to see the code available for this book and all other Wrox books.

Errata

We make every effort to ensure that there are no errors in the text or in the code. However, no one is perfect, and mistakes do occur. If you find an error in one of our books, such as a spelling mistake or a faulty piece of code, we would be very grateful for your feedback. By sending in errata you may save another reader hours of frustration, and at the same time you will be helping us provide even higher quality information.

To find the errata page for this book, go to http://www.wrox.com and locate the title using the Search box or one of the title lists. Then, on the book details page, click the Book Errata link. On this page you can view all errata that has been submitted for this book and posted by Wrox editors. A complete book list, including links to each book's errata, is also available at www.wrox.com/misc-pages/booklist.shtml.

If you don't spot “your” error on the Book Errata page, go to www.wrox.com/contact/techsupport.shtml and complete the form there to send us the error you have found. We'll check the information and, if appropriate, post a message to the book's errata page and fix the problem in subsequent editions of the book.

p2p.wrox.com

For author and peer discussion, join the P2P forums at p2p.wrox.com. The forums are a Web-based system for you to post messages relating to Wrox books and related technologies and interact with other readers and technology users. The forums offer a subscription feature to e-mail you topics of interest of your choosing when new posts are made to the forums. Wrox authors, editors, other industry experts, and your fellow readers are present on these forums.

At http://p2p.wrox.com you will find a number of different forums that will help you not only as you read this book, but also as you develop your own applications. To join the forums, just follow these steps:

Go to

p2p.wrox.com

and click the Register link.

Read the terms of use and click Agree.

Complete the required information to join as well as any optional information you wish to provide and click Submit.

You will receive an e-mail with information describing how to verify your account and complete the joining process.

NOTE

You can read messages in the forums without joining P2P but in order to post your own messages, you must join.

Once you join, you can post new messages and respond to messages other users post. You can read messages at any time on the Web. If you would like to have new messages from a particular forum e-mailed to you, click the Subscribe to This Forum icon by the forum name in the forum listing.

For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to questions about how the forum software works as well as many common questions specific to P2P and Wrox books. To read the FAQs, click the FAQ link on any P2P page.

Chapter 1Getting Started with ASP.NET 6.0

What you will learn in this chapter:

A brief history of ASP.NET and why it supports both Web Forms and MVC

About the two frameworks, Web Forms and MVC

How to install and use Visual Studio 2015

The sample application that will be used throughout this book

Code Downloads for this Chapter:

The wrox.com code downloads for this chapter are found at www.wrox.com/go/beginningaspnetforvisualstudio on the Download Code tab. The code is in the chapter 01 download and individually named according to the names throughout the chapter.

The Internet has become a critical part of life to millions of people across the world. This growth in the use of the Internet has been accelerating since the 1990s and will continue as technology and access becomes more affordable. The Internet has become the go-to source for shopping, leisure, learning, and communications. It has helped to both build new businesses and give revolutionaries the capability to spread their message to the rest of the world.

This growth means that there will be a long-term demand for people with the skills to build and maintain the next generation of web applications. As an increasing percentage of the world's business is accomplished with web applications, learning how to work on these applications is an obvious career move.

An Introduction to ASP.NET vNext

The Internet started off as a set of sealed, private networks designed to share information between research institutions across the United States. The primary users of this system were the research scientists in those labs. However, as the usefulness and flexibility of this information-sharing approach became obvious, interest grew exponentially. More and more institutions became involved, resulting in the evolution of standards and protocols to support the sharing of additional types of information. The initial networks quickly expanded as commercial entities became involved. Soon, Internet service providers were available, enabling regular, everyday people to access and share the burgeoning content of the Internet.

In the early days of the Internet, most content was created and stored statically. Each HTTP request would be for a specific page or piece of stored content, and the response would simply provide that content. Early application frameworks changed that model, enabling the dynamic generation of content based on a certain set of criteria sent as part of that request. This enabled content to be built from databases and other sources, exponentially increasing the usefulness of the Web. It was at this point that the general public, rather than only scientists, really started to take advantage of the Internet's enhanced usability.

ASP.NET is one of those early web application frameworks, with the first version of the .NET Framework released in 2002. The ASP part of the name stands for “Active Server Pages,” which was Microsoft's initial web application framework that used server-side processing to create browser-readable HTML pages. The original ASP, now called “Classic ASP,” allowed the developer to use VBScript to add scripting code to HTML. However, the code and the HTML were all intermingled together in a single file.

ASP.NET was considered a major enhancement at the time because it allowed for a much cleaner separation of the code-behind, the code that handles the processing and markup, the code handling the building of the display, than any of the other frameworks available at that time. There have been improvements to this initial ASP.NET framework with every new release of the .NET Framework.

In 2008 Microsoft introduced a new framework that supported a different approach to content creation and navigation: ASP.NET MVC. MVC stands for Model View Controller, and references a software design pattern that provides a more complete separation between the user interface and the processing code. The original framework became known as Web Forms. Even as the Internet content-creation technologies evolve, the way that the Internet runs stays surprisingly unchanged. The movement of the information from the server to the client follows a very simple protocol that has barely changed since the beginning of the Internet.

Hypertext Transfer Protocol (HTTP)

Hypertext Transfer Protocol (HTTP) is the application protocol that acts as the foundation for communications within the Internet. It defines the interaction between the client machine and the server as following a request-response model whereby the client machine requests, or asks for, a specific resource and the server responds with, or sends a reply about, the information as appropriate.

This request can be very simple, from “show me this picture,” to something very complex, such as a transfer between your bank accounts. Figure 1.1 shows the outcome of that request—whether it is displaying the picture for the first, simple request or whether it is displaying the receipt for the bank transfer from the second, more complex request.

Figure 1.1 Request response

The HTTP protocol also defines what the requests and responses should look like. It includes methods, also known as verbs, which describe what kind of action should be taken on the item being requested. These verbs are not really used that much in ASP.NET Web Forms, but they are especially important in ASP.NET MVC because MVC uses these methods to identify the actions being taken on the requested object. The major verbs are listed in Table 1.1.

Table 1.1 Most Frequently Used HTTP Verbs

Name

Description

GET

A GET is a request for a resource. It should retrieve that resource without any other effect resulting from taking that action. You should be able to GET a resource multiple times.

POST