O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

ASP.NET Core Application Development: Building an application in four sprints (Developer Reference)

Book Description

Master ASP.NET Core hands-on: from architecture through deployment and beyond

This book guides you through the entire process of building, deploying, and managing cross-platform web apps with ASP.NET Core. You’ll master Microsoft’s revolutionary open source ASP.NET Core technology, and learn how to integrate the immense power of MVC, Docker, Azure Web Apps, Visual Studio, C#, JavaScript, and Entity Framework. Working alongside the fictitious development team at Alpine Ski House, you’ll witness a four-sprint journey starting with a blank canvas. You’ll see the team architect and design their software, adjust to user feedback, and move through builds, testing, deployment, maintenance, and refactoring.

Throughout, you’ll discover how to deliver state-of-the-art software faster and more repeatably than ever before.

Three leading Microsoft MVPs show how to:

• Build great cross-platform apps using ASP.NET Core and open source frameworks

• Go beyond MVC to build a complete ASP.Net Core application

• Create builds on Day One and quickly deploy viable products

• Integrate Azure support to gain cloud scalability

• Run or develop cross-platform solutions on Linux

• Establish consistent development environments with Docker

• Access data with Entity Framework Core 1.0

• Generate HTML views with the updated Razor view engine

• Apply the new configuration system and structured logging

• Use identity to enforce security and provide rights

• Improve testability and maintainability with dependency injection

• Use and manage JavaScript in ASP.NET Core environments

• Choose and work with package managers to make life easier

• Use SASS to write maintainable, attractive CSS

• Make the most of tag helpers and other reusable components

• Test web apps efficiently using xUnit.net and Jasmine

• Design, organize, and refactor apps to smoothly accommodate change

Get all code samples, including complete apps, at: https://aka.ms/ASPCoreAppDev/downloads

Table of Contents

  1. Cover
  2. Title Page
  3. Copyright Page
  4. Dedication Page
  5. Contents at a Glance
  6. Table of Contents
  7. Introduction
    1. Who should read this book
      1. Assumptions
    2. This book might not be for you if...
    3. Organization of this book
      1. Finding your best starting point in this book
    4. Conventions and features in this book
    5. System requirements
    6. Downloads: Sample Project
    7. Errata, updates, & book support
    8. Free ebooks from Microsoft Press
    9. We want to hear from you
    10. Stay in touch
  8. Part 1: Alpine Ski House
    1. Chapter 1. How We Got Here
      1. Active Server Pages
      2. ASP.NET
      3. ASP.NET MVC
      4. Web API
      5. ASP.NET Core
      6. Summary
    2. Chapter 2. Influencers
      1. Backward compatibility
      2. Rails
      3. Node.js
      4. Angular and React
      5. Open source
      6. OWIN
      7. Summary
    3. Chapter 3. Models, Views, and Controllers
      1. The M, the V, and the C of it
        1. Diving into Models
        2. Views
        3. Partial Views
        4. Controllers (...and Actions!)
      2. It’s Not Just About MVC
        1. Middleware
        2. Dependency Injection
        3. Other Gems
      3. Summary
    4. Chapter 4. Scoping the Project
      1. Ski Slopes
      2. The API
      3. The Admin View
      4. Pulling the Pieces Together
      5. Defining our Domain
      6. Summary
    5. Chapter 5. Builds
      1. Command Line Builds
      2. Build Servers
      3. The Build Pipeline
      4. Building Alpine Ski House
      5. Summary
    6. Chapter 6. Deployment
      1. Picking a web server
      2. Kestrel
      3. Reverse Proxy
      4. IIS
      5. Nginx
      6. Publishing
        1. Build Types
        2. Building A Package
        3. The Case for Azure
        4. Azure Deployments
      7. Container Deployments
      8. Summary
  9. Part 2: Sprint Retro: A Journey of 1000 Steps
    1. Chapter 7. Building Web Applications with Microsoft Azure
      1. Thinking of Platform as a Service
        1. Platform Services
        2. Scaffolding, Destroying, and Recreating Your Services
      2. Building Applications Using Platform Services
        1. Creating a Storage Account
        2. Storing Images in Blob Containers
        3. Incorporating Storage Queues
        4. Automating Processing with Azure WebJobs
      3. Scaling Out Your Applications
        1. Scaling in Multiple Directions
        2. Scaling with Elasticity
        3. Scaling Considerations
      4. Summary
    2. Chapter 8. Cross-Platform
      1. Up and Running on Ubuntu
        1. Installing .NET Core
        2. The dotnet CLI
      2. Choosing a Code Editor
      3. Alpine Ski House on Linux
      4. .NET Core
      5. Summary
    3. Chapter 9. Containers
      1. Repeatable Environments
      2. Docker
      3. Windows Containers
      4. Docker in Production
      5. On the Cloud
      6. Summary
    4. Chapter 10. Entity Framework Core
      1. Entity Framework Basics
        1. Querying for a single record
        2. Querying for multiple records
        3. Saving Data
        4. Change Tracking
        5. Using Migrations to Create and Update Databases
      2. The ApplicationDbContext
        1. Extending ApplicationUserContext
      3. Ski Card Context
        1. Relationships crossing Context Boundaries
        2. Wiring up the Controller
      4. Pass Types
      5. Passes and Validation
        1. Events and Event Handlers
      6. Summary
    5. Chapter 11. Razor Views
      1. Creating Web Sites as a Developer Today
        1. Building on Previous Successes and Learnings
        2. Understanding Razor’s Role
      2. Mastering Razor Essentials
        1. Peeking Behind the Curtain
        2. Writing Expressions with Razor Syntax
        3. Switching to Code
        4. Explicitly Using Markup
        5. Razor Parser Control Cheat Sheet
      3. Bringing in More C# Features
        1. Using C# Types in Your Views
        2. Defining a Model
        3. Using View Data
      4. Working with Layouts
        1. Foundations of Layouts
        2. Including Sections from Views
        3. Defining and Consuming Partial Views
      5. Enhancing Views with Advanced Razor Functionality
        1. Injecting Services into a View
        2. Working with Tag Helpers
        3. Avoiding Duplication in Your Views
      6. Using Alternate View Engines
      7. Summary
    6. Chapter 12. Configuration and Logging
      1. Moving Away from web.config
        1. Configuring Your Application
        2. Using Stock Configuration Providers
        3. Building a Custom Configuration Provider
        4. Employing the Options Pattern
      2. Logging as a First-Class Citizen
        1. Creating Logs That Provide Clarity
        2. Setting Expectations for Exceptions
        3. Logging as a Development Strategy
        4. Logging Levels in ASP.NET Core
        5. Using Logging Scopes to Augment Logging
        6. Using a Structured Logging Framework
        7. Logging as a Service
      3. Summary
  10. Part 3: Sprint Retro: The Belly of the Beast
    1. Chapter 13. Identity, Security, and Rights Management
      1. Defense in Depth
        1. Internal Threats
        2. External Threats
      2. User Secrets
        1. Azure-Backed Authentication
      3. Identity in ASP.NET Core MVC
        1. Referencing ASP.NET Identity
        2. Local User Accounts
      4. Other Third-Party Authentication Providers
        1. Enabling Security Through Attributes
      5. Using Policies for Authorization
        1. Applying Policies Globally
        2. Defining Policies for Selected Use
        3. Custom Authorization Policies
        4. Protecting Resources
        5. Cross-Origin Resource Sharing (CORS)
      6. Summary
    2. Chapter 14. Dependency Injection
      1. What is Dependency Injection?
        1. Resolving Dependencies Manually
        2. Using a Service Container to Resolve Dependencies
      2. Dependency Injection in ASP.NET Core
        1. Using The Built-In Container
        2. Using a third-party container
      3. Summary
    3. Chapter 15. Role of JavaScript
      1. Writing Good JavaScript
      2. Do We Even Need it?
      3. Organization
      4. To SPA or not to SPA?
      5. Building JavaScript
        1. Bundler & Minifier
        2. Grunt
        3. gulp
        4. WebPack
        5. Which Tool is Right for me?
      6. TypeScript
        1. ES2015 to ES5 Compiler
        2. Typing System
      7. Module Loading
      8. Picking a Framework
      9. Summary
    4. Chapter 16. Dependency Management
      1. NuGet
        1. Installing packages with NuGet
      2. npm
        1. Adding Dependencies
        2. Using npm modules
        3. Visual Studio Integration
      3. Yarn
      4. Bower
        1. Adding Dependencies
        2. Referencing Assets from Bower Packages
      5. Summary
    5. Chapter 17. Front End with Style
      1. Building Websites with Style Sheets
        1. Digging up the Past
        2. Creating Your Own Style Sheet
      2. Getting Sassy with Your Style
        1. Basics of SCSS
        2. Creating Mixins
        3. Mixing Mixins and Directives
      3. Establishing a Development Workflow
        1. Using Command Line Tools
        2. Working in Visual Studio Code
        3. Modifying the Project Build Tasks
      4. Using Third Party Frameworks
        1. Extending a CSS Framework
        2. Customizing a CSS Framework Footprint
        3. Leveraging CSS Frameworks for Custom Style Sheets
        4. Alternatives to CSS Frameworks
      5. Summary
    6. Chapter 18. Caching
      1. Cache Control Headers
      2. Using the Data-Cache
        1. In Memory Cache
        2. Distributed Cache
      3. How Much Cache is Too Much?
      4. Summary
    7. Part 4: Sprint Retro: Home Stretch
    8. Chapter 19. Reusable Components
      1. Tag Helpers
        1. Anatomy of a Tag Helper
        2. Scripts, Links, and Environment Tag Helpers
        3. Cache Tag Helper
        4. Creating Tag Helpers
      2. View Components
        1. Invoking View Components
        2. Contact Customer Service View Component
      3. Partial Views
      4. Summary
    9. Chapter 20. Testing
      1. Unit Testing
        1. XUnit
        2. JavaScript Testing
      2. Other Types of Testing
      3. Summary
    10. Chapter 21. Extensibility
      1. Conventions
        1. Creating Custom Conventions
      2. Middleware
        1. Configuring the pipeline
        2. Writing your own Middleware
        3. Pipeline Branching
      3. Loading External Controller and Views
        1. Loading Views from External Projects
        2. Loading Controllers from External Assemblies
      4. Routing
        1. Attribute Routing
        2. Advanced Routing
      5. Dotnet tools
      6. JavaScript Services and Isomorphic Applications
        1. Isomorphic Applications
        2. Node Services
      7. Summary
    11. Chapter 22. Internationalization
      1. Localizable Text
        1. String Localization
        2. View Localization
        3. Data Annotations
        4. Sharing Resource Files
      2. Setting the Current Culture
      3. Summary
    12. Chapter 23. Refactoring and Improving Code Quality
      1. What is refactoring?
      2. Measuring Quality
      3. Finding Time to Refactor
      4. Refactoring with a Safety Net
      5. Data Driven Changes
      6. A Code Cleanup Example
      7. Tools That Want to Help
      8. Getting to Quality
      9. Summary
    13. Chapter 24. Organizing the Code
      1. Repository Structure
      2. Inside the Source
      3. Parallel Structure
      4. MediatR
        1. A Brief Introduction to the Messaging Pattern
        2. Implementing a Mediator
      5. Areas
      6. Summary
  11. Postfix
  12. Index
  13. About the Authors
  14. Hear about it first
  15. Visit us today
  16. Free ebooks
  17. Survey
  18. Code Snippets