Programming ASP.NET Core, First edition

Book description

The complete, pragmatic guide to building high-value solutions with ASP.NET Core

Programming ASP.NET Core is the definitive guide to practical web-based application development with Microsoft’s new ASP.NET Core framework. Microsoft MVP Dino Esposito introduces proven techniques and well-crafted example code for solving real problems with ASP.NET Core. Step by step, he guides you through using all key ASP.NET Core technologies, including MVC for HTML generation, .NET Core, EF Core, ASP.NET Identity, dependency injection, and much more. Esposito thoroughly covers ASP.NET Core’s cross-platform capabilities and what’s changed from older ASP.NET versions, but he doesn’t stop there: he offers a complete learning path for every developer who wants to build production solutions, including mobile-specific solutions.

Microsoft MVP Dino Esposito shows how to:

  • Create new projects and understand their structure
  • Set up and use the familiar MVC application model in ASP.NET Core
  • Write controller class code to govern all stages of request processing
  • Serve HTML from controllers, or directly via Razor Pages
  • Master the Razor language for quickly defining the layout of HTML views
  • Manage cross-cutting concerns such as global configuration data, error and exception handling, controller class design, and dependency injection
  • Secure applications with user authentication and ASP.NET Core’s policy-based user authorization API
  • Design for efficient data access, and choose the right option for reading and writing data
  • Build ASP.NET Core Web APIs that return JSON, XML, or other data
  • Use data binding to programmatically update visual components with fresh information
  • Build device-friendly web views for iOS and Android
  • Explore the radically new ASP.NET Core runtime environment and Dependency Injection (DI) infrastructure

Table of contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. Contents at a Glance
  5. Contents
  6. About the Author
  7. Introduction
  8. Who should read this book
    1. Assumptions
    2. This might not be for you if
  9. Organization of this book
  10. System requirements
  11. Downloads: Code samples
  12. Errata, updates, & book support
  13. Stay in touch
    1. Chapter 1 Why Another ASP.NET?
      1. The Current .NET Platform
        1. Highlights of the .NET Platform
        2. The .NET Framework
        3. The ASP.NET Framework
        4. The Web API Framework
        5. The Need for Super-Simple Web Services
      2. .NET Fifteen Years Later
        1. A More Compact .NET Framework
        2. Decoupling ASP.NET from the Host
        3. The New ASP.NET Core
      3. .NET Core Command-line Tools
        1. Installing CLI Tools
        2. The dotnet Driver Tool
        3. Predefined dotnet Commands
      4. Summary
    2. Chapter 2 The First ASP.NET Core Project
      1. Anatomy of an ASP.NET Core Project
        1. Structure of the Project
        2. Interacting with the Runtime Environment
      2. The Dependency Injection Subsystem
        1. Dependency Injection at a Glance
        2. Dependency Injection in ASP.NET Core
        3. Integrating with External DI Libraries
      3. Building a Mini Website
        1. Creating a Single Endpoint Website
        2. Accessing Files on the Web Server
      4. Summary
    1. Chapter 3 Bootstrapping ASP.NET MVC
      1. Enabling the MVC Application Model
        1. Registering the MVC Service
        2. Enabling Conventional Routing
      2. Configuring the Routing Table
        1. Anatomy of a Route
        2. Advanced Aspects of Routing
      3. Map of ASP.NET MVC Machinery
        1. The Action Invoker
        2. Processing Action Results
        3. Action Filters
      4. Summary
    2. Chapter 4 ASP.NET MVC Controllers
      1. Controller Classes
        1. Discovering the Controller Name
        2. Inherited Controllers
        3. POCO Controllers
      2. Controller Actions
        1. Mapping Actions to Methods
        2. Attribute-based Routing
      3. Implementation of Action Methods
        1. Basic Data Retrieval
        2. Model Binding
        3. Action Results
      4. Action Filters
        1. Anatomy of Action Filters
        2. Little Gallery of Action Filters
      5. Summary
    3. Chapter 5 ASP.NET MVC Views
      1. Serving HTML Content
        1. Serving HTML from Terminating Middleware
        2. Serving HTML from Controllers
        3. Serving HTML from Razor Pages
      2. The View Engine
        1. Invoking the View Engine
        2. The Razor View Engine
        3. Adding a Custom View Engine
        4. Structure of a Razor View
      3. Passing Data to a View
        1. Built-in Dictionaries
        2. Strongly Typed View Models
        3. Injecting Data through the DI System
      4. Razor Pages
        1. Discovering the Rationale behind Razor Pages
        2. Implementation of Razor Pages
        3. Posting Data from a Razor Page
      5. Summary
    4. Chapter 6 The Razor Syntax
      1. Elements of the Syntax
        1. Processing Code Expressions
        2. Layout Templates
        3. Partial Views
      2. Razor Tag Helpers
        1. Using Tag Helpers
        2. Built-in Tag Helpers
        3. Writing Custom Tag Helpers
      3. Razor View Components
        1. Writing a View Component
        2. The Composition UI Pattern
      4. Summary
    1. Chapter 7 Design Considerations
      1. The Dependency Injection Infrastructure
        1. Refactoring to Isolate Dependencies
        2. Generalities of the ASP.NET Core DI System
        3. Aspects of the DI Container
        4. Injecting Data and Services in Layers
      2. Collecting Configuration Data
        1. Supported Data Providers
        2. Building a Configuration Document Object Model
        3. Passing Configuration Data Around
      3. The Layered Architecture
        1. The Presentation Layer
        2. The Application Layer
        3. The Domain Layer
        4. The Infrastructure Layer
      4. Dealing with Exceptions
        1. Exception Handling Middleware
        2. Exception Filters
        3. Logging Exceptions
      5. Summary
    2. Chapter 8 Securing the Application
      1. Infrastructure for Web Security
        1. The HTTPS Protocol
        2. Dealing with Security Certificates
        3. Applying Encryption to HTTPS
      2. Authentication in ASP.NET Core
        1. Cookie-based Authentication
        2. Dealing with Multiple Authentication Schemes
        3. Modeling the User Identity
        4. External Authentication
      3. Authenticating Users via ASP.NET Identity
        1. Generalities of ASP.NET Identity
        2. Working with the User Manager
      4. Authorization Policies
        1. Role-based Authorization
        2. Policy-based Authorization
      5. Summary
    3. Chapter 9 Access to Application Data
      1. Toward a Relatively Generic Application back end
        1. Monolithic Applications
        2. The CQRS Approach
        3. Inside the Infrastructure Layer
      2. Data Access in .NET Core
        1. Entity Framework 6.x
        2. ADO.NET Adapters
        3. Using Micro O/RM Frameworks
        4. Using NoSQL Stores
      3. EF Core Common Tasks
        1. Modeling a Database
        2. Working with Table Data
        3. Dealing with Transactions
        4. A Word on Async Data Processing
      4. Summary
    1. Chapter 10 Designing a Web API
      1. Building a Web API with ASP.NET Core
        1. Exposing HTTP Endpoints
        2. File Servers
      2. Designing a RESTful Interface
        1. REST at a Glance
        2. REST in ASP.NET Core
      3. Securing a Web API
        1. Planning Just the Security You Really Need
        2. Simpler Access Control Methods
        3. Using an Identity Management Server
      4. Summary
    2. Chapter 11 Posting Data from the Client Side
      1. Organizing HTML Forms
        1. Defining an HTML Form
        2. The Post-Redirect-Get Pattern
      2. Posting Forms Via JavaScript
        1. Uploading the Form Content
        2. Refreshing Portions of the Current Screen
        3. Uploading Files to a Web Server
      3. Summary
    3. Chapter 12 Client-side Data Binding
      1. Refreshing the View via HTML
        1. Preparing the Ground
        2. Defining Refreshable Areas
        3. Putting It All Together
      2. Refreshing the View via JSON
        1. Introducing the Mustache.JS Library
        2. Introducing the KnockoutJS Library
      3. The Angular Way to Building Web Apps
      4. Summary
    4. Chapter 13 Building Device-friendly Views
      1. Adapting Views to the Actual Device
        1. The Best of HTML5 for Device Scenarios
        2. Feature Detection
        3. Client-side Device Detection
        4. Client Hints Coming Soon
      2. Device-friendly Images
        1. The PICTURE Element
        2. The ImageEngine Platform
        3. Resizing Images Automatically
      3. Device-oriented Development Strategies
        1. Client-centric Strategies
        2. Server-centric Strategies
      4. Summary
    1. Chapter 14 The ASP.NET Core Runtime Environment
      1. The ASP.NET Core Host
        1. The WebHost Class
        2. Custom Hosting Settings
      2. The Embedded HTTP Server
        1. Selection of the HTTP Server
        2. Configuring a Reverse Proxy
        3. Kestrel Configuration Parameters
      3. The ASP.NET Core Middleware
        1. Pipeline Architecture
        2. Writing Middleware Components
        3. Packaging Middleware Components
      4. Summary
    2. Chapter 15 Deploying an ASP.NET Core Application
      1. Publishing the Application
        1. Publishing from within Visual Studio
        2. Publishing Using CLI Tools
      2. Deploying the Application
        1. Deploying to IIS
        2. Deploying to Microsoft Azure
        3. Deploying to Linux
      3. Docker Containers
        1. Containers vs. Virtual Machines
        2. From Containers to Microservice Architecture
        3. Docker and Visual Studio 2017
      4. Summary
    3. Chapter 16 Migration and Adoption Strategies
      1. In Search of Business Value
        1. Looking for Benefits
        2. Brownfield Development
        3. Greenfield Development
      2. Outlining a Yellowfield Strategy
        1. Dealing with Missing Dependencies
        2. The .NET Portability Analyzer
        3. The Windows Compatibility Pack
        4. Postponing the Cross-platform Challenge
        5. Moving Towards a Microservice Architecture
      3. Summary
  19. Index
  20. Code Snippets

Product information

  • Title: Programming ASP.NET Core, First edition
  • Author(s): Dino Esposito
  • Release date: May 2018
  • Publisher(s): Microsoft Press
  • ISBN: 9781509304448