ASP.NET 4.0 in Practice
Daniele Bochicchio, Stefano Mostarda, and Marco De Sanctis
  • May 2011
  • ISBN 9781935182467
  • 504 pages
  • printed in black & white

The right book to sharpen your ASP.NET skills.

Alessandro Gallo, MIcrosoft MVP

ASP.NET 4.0 in Practice contains over 100 real world techniques distilled from the experience of a team of MVPs. Using a practical problem-solution-discussion format, the book will guide you through the most common scenarios you will face in a typical ASP.NET application, and provide solutions and suggestions to take your applications to another level.

Table of Contents show full



about this book

about the authors

about the cover illustration

Part 1 ASP.NET Fundamentals

1. Getting acquainted with ASP.NET 4.0

1.1. Meet ASP.NET

1.2. Typical architecture in ASP.NET applications

1.3. Your first ASP.NET Web Form

1.4. What’s new in ASP.NET 4.0

1.5. ASP.NET Web Forms in practice

Technique 1 Handling PostBack

Technique 2 Form validation

Technique 3 Page header, styling, and CSS

1.6. Summary

2. Data access reloaded: Entity Framework

2.1. Designing an application

2.2. Using an ORM to build a data layer

2.3. Introducing Entity Framework

Technique 4 Creating a model using Entity Framework

Technique 5 Generating POCO code

Technique 6 Reading data using Entity Framework

Technique 7 Writing data using Entity Framework

2.4. Summary

3. Integrating Entity Framework and ASP.NET

3.1. Understanding context lifetime

Technique 8 First approach: one context per method

Technique 9 A better approach: one context per ASP.NET request

Technique 10 Instantiating the context using modules

3.2. Using the context the right way

Technique 11 Persisting entity modifications

Technique 12 Persisting only selected properties

Technique 13 Persisting an entity using ViewState

Technique 14 Keep concurrency in mind

3.3. Optimizing performance in an ASP.NET environment

Technique 15 Optimizing fetching

Technique 16 Avoiding multiple query execution

Technique 17 Optimizing queries that retrieve a single element

Technique 18 Disabling change tracking

3.4. Summary

Part 2 ASP.NET Web Forms

4. Building the user interface with ASP.NET Web Forms

4.1. The UI and Web Forms

Technique 19 Better markup generation in ASP.NET 4.0

Technique 20 Controlling ClientID generation

4.2. Defining a common UI: using master pages

Technique 21 Using nested master pages

Technique 22 Setting a master page programmatically

4.3. URL rewriting and routing with ASP.NET

Technique 23 URL routing with Web Forms

Technique 24 Advanced URL routing scenarios

Technique 25 Rewriting in practice: UrlRewriting.NET

4.4. Summary

5. Data binding in ASP.NET Web Forms

5.1. Displaying data

Technique 26 How to display data using Repeater

Technique 27 ListView in ASP.NET 4.0

5.2. Modifying data

Technique 28 Using data source controls

Technique 29 EntityDataSource and Entity Framework

Technique 30 What’s new in GridView, FormView, and ListView

5.3. Filtering and sorting data

Technique 31 The QueryExtender control

5.4. Working with Dynamic Data controls

Technique 32 The first application

Technique 33 Working with metadata and templates

Technique 34 Extending Dynamic Data

5.5. Summary

6. Custom controls

6.1. The basics of custom controls

Technique 35 Simple controls

Technique 36 Composite controls

Technique 37 Handling PostBack

6.2. Complex controls

Technique 38 Container controls

Technique 39 Templated controls

Technique 40 Data binding in custom controls

6.3. Advanced controls

Technique 41 Control builders

6.4. Summary

7. Taking control of markup

7.1. ASP.NET adaptive rendering

Technique 42 Add OptionGroups to DropDownList

Technique 43 Build a table-less control adapter for the DataList

7.2. ASP.NET 4.0 browser capabilities

Technique 44 Building a custom browser capabilities provider

Technique 45 Validating ASP.NET pages with the W3C validator

7.3. Summary


8. Introducing ASP.NET MVC

8.1. A new way to build web applications

8.2. Your first experience with ASP.NET MVC

Technique 46 The model

Technique 47 The controller

Technique 48 The view

8.3. Routing in ASP.NET MVC

Technique 49 Partitioning using Areas

8.4. Accepting user input

Technique 50 Handling user input at the controller level

Technique 51 Validating posted data

8.5. Summary

9. Customizing and extending ASP.NET MVC

9.1. Building reusable elements in ASP.NET MVC

Technique 52 Building customized data templates

Technique 53 Componentized markup through HTML helpers

Technique 54 Inject logic using action filters

9.2. User input handling made smart

Technique 55 Custom model binders for domain entities

Technique 56 Building a new model binder from scratch

9.3. Improving ASP.NET MVC routing

Technique 57 Routes with consistent URL termination

9.4. Summary

Part 4 Security

10. ASP.NET security

10.1. What is security in ASP.NET applications?

10.2. Filtering and blocking incoming requests

Technique 58 Handling improper parameter values

Technique 59 Monitoring and blocking bad requests

10.3. Protecting applications from SQL injection

Technique 60 Handling SQL queries using parameters

Technique 61 Dynamic queries with multiple values

10.4. Dealing with XSS (cross-site scripting)

Technique 62 Handling and displaying user input

Technique 63 Using Microsoft’s Anti-XSS Library

10.5. Controlling path composition: path canonicalization vulnerabilities

Technique 64 Dynamically building a path

10.6. Summary

11. ASP.NET authentication and authorization

11.1. Authentication and authorization basics

Technique 65 Using FormsAuthentication and UrlAuthorization

11.2. Handling user authentication: introducing the Membership API

Technique 66 Implementing a user login using the Membership API

11.3. Adding support to roles using the Roles API

Technique 67 Implementing a role-enabled login using Roles API

11.4. Custom providers for the Membership and Roles APIs

Technique 68 Other providers

Technique 69 Building custom Membership and Role providers

Technique 70 Integrating Windows Live ID with your application

11.5. Summary

Part 5 Advanced topics

12. Ajax and RIAs with ASP.NET 4.0

12.1. Understanding Ajax

12.2. Working with ASP.NET Ajax

Technique 71 Creating a classic page

Technique 72 Ajaxize a page using the update panel

Technique 73 Optimizing UpdatePanel using triggers

Technique 74 Optimizing a page with multiple UpdatePanels

Technique 75 Intercepting client-side pipeline

12.3. Focusing on the client: jQuery

Technique 76 Invoking REST web services with jQuery

Technique 77 Invoking page methods with jQuery

Technique 78 Invoking MVC actions with jQuery

Technique 79 Enriching the interface via jQueryUI

12.4. Summary

13. State

13.1. Handling state

Technique 80 Per-request state

Technique 81 Per-session state

13.2. Advanced user state

Technique 82 Using the Profile API

Technique 83 A custom provider for the Profile API

13.3. Summary

14. Caching in ASP.NET

14.1. Per-application state: Cache

14.2. Using OutputCache

Technique 84 Leveraging OutputCache to speed up your pages

14.3. OutputCache in ASP.NET MVC

Technique 85 Deterministically removing items from OutputCache

Technique 86 OutputCache and partial views

14.4. Data caching techniques

Technique 87 Implementing data caching in ASP.NET

14.5. Building custom cache providers

Technique 88 Custom cache provider

Technique 89 Custom OutputCache provider

14.6. Summary

15. Extreme ASP.NET 4.0

15.1. Using HttpModules

Technique 90 Modifying the response flow with HttpModules

Technique 91 Intercepting and handling mobile device requests

15.2. Logging and handling errors

Technique 92 Intercepting, and handling errors with a custom module

15.3. Extending ASP.NET HttpRuntime

Technique 93 Running your site from the database

15.4. Summary

16. Performance and optimizations

16.1. Increasing download performance by minifying

Technique 94 Building a request filter to minify HTML

Technique 95 Building an HTTPHandler to minify CSS

Technique 96 Building an HTTPHandler to minify JavaScript

16.2. Reducing computing time with multithreading

Technique 97 Increasing performance with multithreading

Technique 98 Using ParallelFX

16.3. Optimize your web.config

Technique 99 Tips for your web.config

16.4. Summary

Appendix A: ASP.NET and IIS 7.x

Technique 100 Modifying IIS behavior with managed modules

Technique 101 Configuring application warm-up in IIS 7.5

Appendix B: Data access fundamentals

Technique 102 UsiQuerying the database using ADO.NET

Technique 103 Using stored procedures to query the database

Technique 104 Persisting data into the database

Technique 105 Writing XML

Technique 106 Generating XML from a data source

Technique 107 Reading XML


About the Technology

ASP.NET is an established technology to build web applications using Microsoft products. It drives a number of enterprise-level web sites around the world, but it can be scaled for projects of any size. The new version 4.0 is an evolutionary step: you will find a lot of new features that you will be able to leverage to build better web applications with minimal effort.

About the book

ASP.NET is a massive framework that requires a large amount of know-how from developers. Fortunately, this book distills over 100 practical ASP.NET techniques from the experience of a team of MVPs, and puts them right at your fingertips.

The techniques are tested and selected for their usefulness, and they are all presented in a simple problem-solution-discussion format. You'll discover methods for key new subjects like data integration with Entity Framework and ASP.NET MVC. Along the way, you'll also find ways to make your applications fast and secure.

What's inside

  • The Identity Map pattern in EF 4
  • Use Master Pages to define a common UI
  • Adaptive Rendering
  • Save user login data securely
  • ... and much more

About the reader

This book is written for developers familiar with the basics of ASP.NET, looking to become more productive with it.

About the authors

Daniele Bochicchio, Stefano Mostarda, and Marco De Sanctis are ASP.NET MVPs and core members of, Italy's largest .NET community. They are also the authors of Manning's Entity Framework 4 in Action.

eBook $43.99 pdf + ePub + kindle

FREE domestic shipping on three or more pBooks

Easy to read, full of extremely helpful techniques.

David Barkol, Neudesic

A great way to learn an exciting new technology.

Gary A. Bushey, ShareTech Consulting

Get up to speed in no time.

Nikander and Margriet Bruggeman, Lois & Clark IT Services