C# 9 and .NET 5 – Modern Cross-Platform Development - Fifth Edition

Book description

Publisher’s Note: Microsoft stopped supporting .NET 5 in May 2022. The newer 8th edition of the book is available that covers .NET 8 (end-of-life November 2026) with C# 12 and EF Core 8. Purchase of the print or Kindle book includes a free PDF eBook

Key Features

  • Explore the newest additions to C# 9, the .NET 5 class library, Entity Framework Core and Blazor
  • Strengthen your command of ASP.NET Core 5.0 and create professional websites and services
  • Build cross-platform apps for Windows, macOS, Linux, iOS, and Android

Book Description

In C# 9 and .NET 5 – Modern Cross-Platform Development, Fifth Edition, expert teacher Mark J. Price gives you everything you need to start programming C# applications.

This latest edition uses the popular Visual Studio Code editor to work across all major operating systems. It is fully updated and expanded with a new chapter on the Microsoft Blazor framework.

The book’s first part teaches the fundamentals of C#, including object-oriented programming and new C# 9 features such as top-level programs, target-typed new object instantiation, and immutable types using the record keyword. Part 2 covers the .NET APIs, for performing tasks like managing and querying data, monitoring and improving performance, and working with the file system, async streams, serialization, and encryption. Part 3 provides examples of cross-platform apps you can build and deploy, such as websites and services using ASP.NET Core or mobile apps using Xamarin.Forms. The best type of application for learning the C# language constructs and many of the .NET libraries is one that does not distract with unnecessary application code. For that reason, the C# and .NET topics covered in Chapters 1 to 13 feature console applications. In Chapters 14 to 20, having mastered the basics of the language and libraries, you will build practical applications using ASP.NET Core, Model-View-Controller (MVC), and Blazor.

By the end of the book, you will have acquired the understanding and skills you need to use C# 9 and .NET 5 to create websites, services, and mobile apps.

What you will learn

  • Build your own types with object-oriented programming
  • Query and manipulate data using LINQ
  • Build websites and services using ASP.NET Core 5
  • Create intelligent apps using machine learning
  • Use Entity Framework Core and work with relational databases
  • Discover Windows app development using the Universal Windows Platform and XAML
  • Build rich web experiences using the Blazor framework
  • Build mobile applications for iOS and Android using Xamarin.Forms

Who this book is for

This book is best for C# and .NET beginners, or programmers who have worked with C# in the past but feel left behind by the changes in the past few years. This book doesn’t expect you to have any C# or .NET experience; however, you should have a general understanding of programming. Students and professionals with a science, technology, engineering, or mathematics (STEM) background can certainly benefit from this book.

Table of contents

  1. Preface
    1. What this book covers
    2. What you need for this book
      1. Downloading the color images of this book
      2. Conventions
    3. Get in touch
      1. Reviews
  2. Hello, C#! Welcome, .NET!
    1. Setting up your development environment
      1. Using Visual Studio Code for cross-platform development
      2. Using GitHub Codespaces for development in the cloud
      3. Using Visual Studio 2019 for Windows app development
      4. Using Visual Studio for Mac for mobile development
      5. Recommended tools for chapters
      6. Deploying cross-platform
      7. Understanding Microsoft Visual Studio Code versions
      8. Downloading and installing Visual Studio Code
      9. Installing other extensions
    2. Understanding .NET
      1. Understanding .NET Framework
      2. Understanding the Mono and Xamarin projects
      3. Understanding .NET Core
      4. Understanding .NET 5 and the journey to one .NET
      5. Understanding .NET support
      6. Understanding .NET Runtime and .NET SDK versions
      7. Removing old versions of .NET
      8. What is different about .NET Core and .NET 5?
      9. Understanding .NET Standard
      10. .NET platforms and tools used by the book editions
      11. Understanding intermediate language
      12. Comparing .NET technologies
    3. Building console apps using Visual Studio Code
      1. Writing code using Visual Studio Code
      2. Compiling and running code using the dotnet CLI
      3. Writing top-level programs
    4. Downloading solution code from the GitHub repository
      1. Using Git with Visual Studio Code
      2. Cloning the book solution code repository
    5. Looking for help
      1. Reading Microsoft documentation
      2. Getting help for the dotnet tool
      3. Getting definitions of types and their members
      4. Looking for answers on Stack Overflow
      5. Searching for answers using Google
      6. Subscribing to the official .NET blog
      7. Scott Hanselman's videos
    6. Practicing and exploring
      1. Exercise 1.1 – Test your knowledge
      2. Exercise 1.2 – Practice C# anywhere
      3. Exercise 1.3 – Explore topics
    7. Summary
  3. Speaking C#
    1. Introducing C#
      1. Understanding language versions and features
        1. C# 1.0
        2. C# 2.0
        3. C# 3.0
        4. C# 4.0
        5. C# 5.0
        6. C# 6.0
        7. C# 7.0
        8. C# 7.1
        9. C# 7.2
        10. C# 7.3
        11. C# 8.0
        12. C# 9.0
      2. Discovering your C# compiler versions
      3. Enabling a specific language version compiler
    2. Understanding C# basics
      1. Understanding C# grammar
        1. Statements
        2. Comments
        3. Blocks
      2. Understanding C# vocabulary
        1. Changing the color scheme for syntax
        2. Comparing programming languages to human languages
        3. Help for writing correct code
        4. Verbs are methods
        5. Nouns are types, fields, and variables
        6. Revealing the extent of the C# vocabulary
    3. Working with variables
      1. Naming things and assigning values
        1. Literal values
      2. Storing text
        1. Understanding verbatim strings
      3. Storing numbers
        1. Storing whole numbers
        2. Storing real numbers
        3. Writing code to explore number sizes
        4. Comparing double and decimal types
      4. Storing Booleans
      5. Using Visual Studio Code workspaces
      6. Storing any type of object
      7. Storing dynamic types
      8. Declaring local variables
        1. Specifying and inferring the type of a local variable
        2. Using target-typed new to instantiate objects
      9. Getting default values for types
      10. Storing multiple values
    4. Working with null values
      1. Making a value type nullable
        1. Understanding nullable reference types
      2. Enabling nullable and non-nullable reference types
      3. Declaring non-nullable variables and parameters
      4. Checking for null
    5. Exploring console applications further
      1. Displaying output to the user
        1. Formatting using numbered positional arguments
        2. Formatting using interpolated strings
      2. Understanding format strings
      3. Getting text input from the user
      4. Importing a namespace
      5. Simplifying the usage of the console
      6. Getting key input from the user
      7. Getting arguments
      8. Setting options with arguments
      9. Handling platforms that do not support an API
    6. Practicing and exploring
      1. Exercise 2.1 – Test your knowledge
      2. Exercise 2.2 – Practice number sizes and ranges
      3. Exercise 2.3 – Explore topics
    7. Summary
  4. Controlling Flow and Converting Types
    1. Operating on variables
      1. Unary operators
      2. Binary arithmetic operators
      3. Assignment operators
      4. Logical operators
      5. Conditional logical operators
      6. Bitwise and binary shift operators
      7. Miscellaneous operators
    2. Understanding selection statements
      1. Branching with the if statement
      2. Why you should always use braces with if statements
      3. Pattern matching with the if statement
      4. Branching with the switch statement
      5. Pattern matching with the switch statement
      6. Simplifying switch statements with switch expressions
    3. Understanding iteration statements
      1. Looping with the while statement
      2. Looping with the do statement
      3. Looping with the for statement
      4. Looping with the foreach statement
        1. Understanding how foreach works internally
    4. Casting and converting between types
      1. Casting numbers implicitly and explicitly
      2. Converting with the System.Convert type
      3. Rounding numbers
        1. Understanding the default rounding rules
        2. Taking control of rounding rules
      4. Converting from any type to a string
      5. Converting from a binary object to a string
      6. Parsing from strings to numbers or dates and times
        1. Avoiding exceptions using the TryParse method
      7. Handling exceptions when converting types
        1. Wrapping error-prone code in a try block
        2. Catching all exceptions
        3. Catching specific exceptions
      8. Checking for overflow
        1. Throwing overflow exceptions with the checked statement
        2. Disabling compiler overflow checks with the unchecked statement
    5. Practicing and exploring
      1. Exercise 3.1 – Test your knowledge
      2. Exercise 3.2 – Explore loops and overflow
      3. Exercise 3.3 – Practice loops and operators
      4. Exercise 3.4 – Practice exception handling
      5. Exercise 3.5 – Test your knowledge of operators
      6. Exercise 3.6 – Explore topics
    6. Summary
  5. Writing, Debugging, and Testing Functions
    1. Writing functions
      1. Writing a times table function
      2. Writing a function that returns a value
      3. Writing mathematical functions
        1. Converting numbers from cardinal to ordinal
        2. Calculating factorials with recursion
      4. Documenting functions with XML comments
      5. Using lambdas in function implementations
    2. Debugging during development
      1. Creating code with a deliberate bug
      2. Setting a breakpoint
      3. Navigating with the debugging toolbar
      4. Debugging windows
      5. Stepping through code
      6. Customizing breakpoints
    3. Logging during development and runtime
      1. Instrumenting with Debug and Trace
      2. Writing to the default trace listener
      3. Configuring trace listeners
      4. Switching trace levels
    4. Unit testing functions
      1. Creating a class library that needs testing
      2. Writing unit tests
      3. Running unit tests
    5. Practicing and exploring
      1. Exercise 4.1 – Test your knowledge
      2. Exercise 4.2 – Practice writing functions with debugging and unit testing
      3. Exercise 4.3 – Explore topics
    6. Summary
  6. Building Your Own Types with Object-Oriented Programming
    1. Talking about object-oriented programming
    2. Building class libraries
      1. Creating a class library
        1. Defining a class
        2. Understanding members
      2. Instantiating a class
        1. Referencing an assembly
        2. Importing a namespace to use a type
      3. Managing multiple files
      4. Understanding objects
        1. Inheriting from System.Object
    3. Storing data within fields
      1. Defining fields
      2. Understanding access modifiers
      3. Setting and outputting field values
      4. Storing a value using an enum type
      5. Storing multiple values using an enum type
      6. Storing multiple values using collections
      7. Making a field static
      8. Making a field constant
      9. Making a field read-only
      10. Initializing fields with constructors
      11. Setting fields with default literals
    4. Writing and calling methods
      1. Returning values from methods
      2. Combining multiple returned values using tuples
        1. Naming the fields of a tuple
        2. Inferring tuple names
        3. Deconstructing tuples
      3. Defining and passing parameters to methods
      4. Overloading methods
      5. Passing optional parameters and naming arguments
      6. Controlling how parameters are passed
        1. Understanding ref returns
      7. Splitting classes using partial
    5. Controlling access with properties and indexers
      1. Defining read-only properties
      2. Defining settable properties
      3. Defining indexers
    6. Pattern matching with objects
      1. Creating and referencing a .NET 5 class library
      2. Defining flight passengers
      3. Enhancements to pattern matching in C# 9
    7. Working with records
      1. Init-only properties
      2. Understanding records
      3. Simplifying data members
      4. Positional records
    8. Practicing and exploring
      1. Exercise 5.1 – Test your knowledge
      2. Exercise 5.2 – Explore topics
    9. Summary
  7. Implementing Interfaces and Inheriting Classes
    1. Setting up a class library and console application
    2. Simplifying methods
      1. Implementing functionality using methods
      2. Implementing functionality using operators
      3. Implementing functionality using local functions
    3. Raising and handling events
      1. Calling methods using delegates
      2. Defining and handling delegates
      3. Defining and handling events
    4. Implementing interfaces
      1. Common interfaces
      2. Comparing objects when sorting
      3. Comparing objects using a separate class
      4. Defining interfaces with default implementations
    5. Making types safely reusable with generics
      1. Working with generic types
      2. Working with generic methods
    6. Managing memory with reference and value types
      1. Working with struct types
      2. Releasing unmanaged resources
      3. Ensuring that Dispose is called
    7. Inheriting from classes
      1. Extending classes to add functionality
      2. Hiding members
      3. Overriding members
      4. Preventing inheritance and overriding
      5. Understanding polymorphism
    8. Casting within inheritance hierarchies
      1. Implicit casting
      2. Explicit casting
      3. Avoiding casting exceptions
    9. Inheriting and extending .NET types
      1. Inheriting exceptions
      2. Extending types when you can't inherit
        1. Using static methods to reuse functionality
        2. Using extension methods to reuse functionality
    10. Practicing and exploring
      1. Exercise 6.1 – Test your knowledge
      2. Exercise 6.2 – Practice creating an inheritance hierarchy
      3. Exercise 6.3 – Explore topics
    11. Summary
  8. Understanding and Packaging .NET Types
    1. Introducing .NET 5
      1. .NET Core 1.0
      2. .NET Core 1.1
      3. .NET Core 2.0
      4. .NET Core 2.1
      5. .NET Core 2.2
      6. .NET Core 3.0
      7. .NET 5.0
      8. Improving performance from .NET Core 2.0 to .NET 5
    2. Understanding .NET components
      1. Understanding assemblies, packages, and namespaces
        1. Understanding dependent assemblies
        2. Understanding the Microsoft .NET project SDKs
        3. Understanding NuGet packages
        4. Understanding frameworks
      2. Importing a namespace to use a type
      3. Relating C# keywords to .NET types
      4. Sharing code with legacy platforms using .NET Standard
      5. Creating a .NET Standard 2.0 class library
    3. Publishing your applications for deployment
      1. Creating a console application to publish
      2. Understanding dotnet commands
        1. Creating new projects
        2. Managing projects
      3. Publishing a self-contained app
      4. Publishing a single-file app
      5. Reducing the size of apps using app trimming
    4. Decompiling assemblies
    5. Packaging your libraries for NuGet distribution
      1. Referencing a NuGet package
        1. Fixing dependencies
      2. Packaging a library for NuGet
      3. Testing your package
    6. Porting from .NET Framework to .NET 5
      1. Could you port?
      2. Should you port?
      3. Differences between .NET Framework and .NET 5
      4. Understanding the .NET Portability Analyzer
      5. Using non-.NET Standard libraries
    7. Practicing and exploring
      1. Exercise 7.1 – Test your knowledge
      2. Exercise 7.2 – Explore topics
    8. Summary
  9. Working with Common .NET Types
    1. Working with numbers
      1. Working with big integers
      2. Working with complex numbers
    2. Working with text
      1. Getting the length of a string
      2. Getting the characters of a string
      3. Splitting a string
      4. Getting part of a string
      5. Checking a string for content
      6. Joining, formatting, and other string members
      7. Building strings efficiently
    3. Pattern matching with regular expressions
      1. Checking for digits entered as text
      2. Understanding the syntax of a regular expression
      3. Examples of regular expressions
      4. Splitting a complex comma-separated string
      5. Regular expression performance improvements
    4. Storing multiple objects in collections
      1. Common features of all collections
      2. Understanding collection choices
        1. Lists
        2. Dictionaries
        3. Stacks
        4. Queues
        5. Sets
      3. Working with lists
      4. Working with dictionaries
      5. Sorting collections
      6. Using specialized collections
      7. Using immutable collections
    5. Working with spans, indexes, and ranges
      1. Using memory efficiently using spans
      2. Identifying positions with the Index type
      3. Identifying ranges with the Range type
      4. Using indexes and ranges
    6. Working with network resources
      1. Working with URIs, DNS, and IP addresses
      2. Pinging a server
    7. Working with types and attributes
      1. Versioning of assemblies
      2. Reading assembly metadata
      3. Creating custom attributes
      4. Doing more with reflection
    8. Working with images
    9. Internationalizing your code
      1. Detecting and changing the current culture
      2. Handling time zones
    10. Practicing and exploring
      1. Exercise 8.1 – Test your knowledge
      2. Exercise 8.2 – Practice regular expressions
      3. Exercise 8.3 – Practice writing extension methods
      4. Exercise 8.4 – Explore topics
    11. Summary
  10. Working with Files, Streams, and Serialization
    1. Managing the filesystem
      1. Handling cross-platform environments and filesystems
      2. Managing drives
      3. Managing directories
      4. Managing files
      5. Managing paths
      6. Getting file information
      7. Controlling how you work with files
    2. Reading and writing with streams
      1. Writing to text streams
      2. Writing to XML streams
      3. Disposing of file resources
      4. Compressing streams
      5. Compressing with the Brotli algorithm
      6. High-performance streams using pipelines
      7. Asynchronous streams
    3. Encoding and decoding text
      1. Encoding strings as byte arrays
      2. Encoding and decoding text in files
    4. Serializing object graphs
      1. Serializing as XML
      2. Generating compact XML
      3. Deserializing XML files
      4. Serializing with JSON
      5. High-performance JSON processing
    5. Practicing and exploring
      1. Exercise 9.1 – Test your knowledge
      2. Exercise 9.2 – Practice serializing as XML
      3. Exercise 9.3 – Explore topics
    6. Summary
  11. Protecting Your Data and Applications
    1. Understanding the vocabulary of protection
      1. Keys and key sizes
      2. IVs and block sizes
      3. Salts
      4. Generating keys and IVs
    2. Encrypting and decrypting data
      1. Encrypting symmetrically with AES
    3. Hashing data
      1. Hashing with the commonly used SHA256
    4. Signing data
      1. Signing with SHA256 and RSA
    5. Generating random numbers
      1. Generating random numbers for games
      2. Generating random numbers for cryptography
    6. What's new in cryptography?
    7. Authenticating and authorizing users
      1. Implementing authentication and authorization
      2. Protecting application functionality
    8. Practicing and exploring
      1. Exercise 10.1 – Test your knowledge
      2. Exercise 10.2 – Practice protecting data with encryption and hashing
      3. Exercise 10.3 – Practice protecting data with decryption
      4. Exercise 10.4 – Explore topics
    9. Summary
  12. Working with Databases Using Entity Framework Core
    1. Understanding modern databases
      1. Understanding legacy Entity Framework
      2. Understanding Entity Framework Core
      3. Using a sample relational database
        1. Setting up SQLite for macOS
        2. Setting up SQLite for Windows
      4. Creating the Northwind sample database for SQLite
      5. Managing the Northwind sample database with SQLiteStudio
    2. Setting up EF Core
      1. Choosing an EF Core database provider
      2. Setting up the dotnet-ef tool
      3. Connecting to the database
    3. Defining EF Core models
      1. EF Core conventions
      2. EF Core annotation attributes
      3. EF Core Fluent API
      4. Understanding data seeding
      5. Building an EF Core model
        1. Defining the Category and Product entity classes
        2. Defining the Northwind database context class
      6. Scaffolding models using an existing database
    4. Querying EF Core models
      1. Filtering included entities
      2. Filtering and sorting products
      3. Getting the generated SQL
      4. Logging EF Core
      5. Logging with query tags
      6. Pattern matching with Like
      7. Defining global filters
    5. Loading patterns with EF Core
      1. Eager loading entities
      2. Enabling lazy loading
      3. Explicit loading entities
    6. Manipulating data with EF Core
      1. Inserting entities
      2. Updating entities
      3. Deleting entities
      4. Pooling database contexts
      5. Transactions
        1. Defining an explicit transaction
    7. Practicing and exploring
      1. Exercise 11.1 – Test your knowledge
      2. Exercise 11.2 – Practice exporting data using different serialization formats
      3. Exercise 11.3 – Explore the EF Core documentation
    8. Summary
  13. Querying and Manipulating Data Using LINQ
    1. Writing LINQ queries
      1. Extending sequences with the Enumerable class
      2. Filtering entities with Where
        1. Targeting a named method
        2. Simplifying the code by removing the explicit delegate instantiation
        3. Targeting a lambda expression
      3. Sorting entities
        1. Sorting by a single property using OrderBy
        2. Sorting by a subsequent property using ThenBy
      4. Filtering by type
    2. Working with sets and bags using LINQ
    3. Using LINQ with EF Core
      1. Building an EF Core model
      2. Filtering and sorting sequences
      3. Projecting sequences into new types
      4. Joining and grouping sequences
      5. Aggregating sequences
    4. Sweetening LINQ syntax with syntactic sugar
    5. Using multiple threads with parallel LINQ
      1. Creating an app that benefits from multiple threads
        1. Using Windows 10
        2. Using macOS
        3. For all operating systems
    6. Creating your own LINQ extension methods
    7. Working with LINQ to XML
      1. Generating XML using LINQ to XML
      2. Reading XML using LINQ to XML
    8. Practicing and exploring
      1. Exercise 12.1 – Test your knowledge
      2. Exercise 12.2 – Practice querying with LINQ
      3. Exercise 12.3 – Explore topics
    9. Summary
  14. Improving Performance and Scalability Using Multitasking
    1. Understanding processes, threads, and tasks
    2. Monitoring performance and resource usage
      1. Evaluating the efficiency of types
      2. Monitoring performance and memory use
      3. Implementing the Recorder class
        1. Measuring the efficiency of processing strings
    3. Running tasks asynchronously
      1. Running multiple actions synchronously
      2. Running multiple actions asynchronously using tasks
      3. Waiting for tasks
      4. Continuing with another task
      5. Nested and child tasks
    4. Synchronizing access to shared resources
      1. Accessing a resource from multiple threads
      2. Applying a mutually exclusive lock to a resource
      3. Understanding the lock statement and avoiding deadlocks
      4. Synchronizing events
      5. Making CPU operations atomic
      6. Applying other types of synchronization
    5. Understanding async and await
      1. Improving responsiveness for console apps
      2. Improving responsiveness for GUI apps
      3. Improving scalability for web applications and web services
      4. Common types that support multitasking
      5. Using await in catch blocks
      6. Working with async streams
    6. Practicing and exploring
      1. Exercise 13.1 – Test your knowledge
      2. Exercise 13.2 – Explore topics
    7. Summary
  15. Introducing Practical Applications of C# and .NET
    1. Understanding app models for C# and .NET
      1. Building websites using ASP.NET Core
      2. Building websites using a web content management system
      3. Understanding web applications
      4. Building and consuming web services
      5. Building intelligent apps
    2. New features in ASP.NET Core
      1. ASP.NET Core 1.0
      2. ASP.NET Core 1.1
      3. ASP.NET Core 2.0
      4. ASP.NET Core 2.1
      5. ASP.NET Core 2.2
      6. ASP.NET Core 3.0
      7. ASP.NET Core 3.1
      8. Blazor WebAssembly 3.2
      9. ASP.NET Core 5.0
    3. Understanding SignalR
    4. Understanding Blazor
      1. JavaScript and friends
      2. Silverlight – C# and .NET using a plugin
      3. WebAssembly – a target for Blazor
      4. Blazor on the server side or client side
    5. Understanding the bonus chapters
      1. Building cross-platform mobile and desktop apps
      2. Building Windows desktop apps using legacy technologies
    6. Building an entity data model for Northwind
      1. Creating a class library for Northwind entity models
        1. Generating entity models using dotnet-ef
        2. Manually improving the class-to-table mapping
      2. Creating a class library for a Northwind database context
    7. Summary
  16. Building Websites Using ASP.NET Core Razor Pages
    1. Understanding web development
      1. Understanding HTTP
      2. Client-side web development
    2. Understanding ASP.NET Core
      1. Classic ASP.NET versus modern ASP.NET Core
      2. Creating an ASP.NET Core project
      3. Testing and securing the website
      4. Controlling the hosting environment
      5. Enabling static and default files
    3. Exploring Razor Pages
      1. Enabling Razor Pages
      2. Defining a Razor Page
      3. Using shared layouts with Razor Pages
      4. Using code-behind files with Razor Pages
    4. Using Entity Framework Core with ASP.NET Core
      1. Configure Entity Framework Core as a service
      2. Manipulating data using Razor Pages
        1. Enabling a model to insert entities
        2. Defining a form to insert new suppliers
    5. Using Razor class libraries
      1. Creating a Razor class library
      2. Disabling compact folders
      3. Implementing the employees feature using EF Core
      4. Implementing a partial view to show a single employee
      5. Using and testing a Razor class library
    6. Configuring services and the HTTP request pipeline
      1. Registering services
      2. Configuring the HTTP request pipeline
      3. Simplest possible ASP.NET Core website project
    7. Practicing and exploring
      1. Exercise 15.1 – Test your knowledge
      2. Exercise 15.2 – Practice building a data-driven web page
      3. Exercise 15.3 – Practice building web pages for console apps
      4. Exercise 15.4 – Explore topics
    8. Summary
  17. Building Websites Using the Model-View-Controller Pattern
    1. Setting up an ASP.NET Core MVC website
      1. Creating and exploring an ASP.NET Core MVC website
      2. Reviewing the ASP.NET Core MVC website
      3. Reviewing the ASP.NET Core Identity database
    2. Exploring an ASP.NET Core MVC website
      1. Understanding ASP.NET Core MVC startup
      2. Understanding the default MVC route
      3. Understanding controllers and actions
      4. Understanding the view search path convention
      5. Unit testing MVC
      6. Understanding filters
        1. Using a filter to secure an action method
        2. Using a filter to cache a response
        3. Using a filter to define a custom route
      7. Understanding entity and view models
      8. Understanding views
    3. Customizing an ASP.NET Core MVC website
      1. Defining a custom style
      2. Setting up the category images
      3. Understanding Razor syntax
      4. Defining a typed view
      5. Reviewing the customized home page
      6. Passing parameters using a route value
      7. Understanding model binders
      8. Validating the model
      9. Understanding view helper methods
      10. Querying a database and using display templates
      11. Improving scalability using asynchronous tasks
        1. Making controller action methods asynchronous
    4. Using other project templates
      1. Installing additional template packs
    5. Practicing and exploring
      1. Exercise 16.1 – Test your knowledge
      2. Exercise 16.2 – Practice implementing MVC by implementing a category detail page
      3. Exercise 16.3 – Practice improving scalability by understanding and implementing async action methods
      4. Exercise 16.4 – Explore topics
    6. Summary
  18. Building Websites Using a Content Management System
    1. Understanding the benefits of a CMS
      1. Understanding basic CMS features
      2. Understanding enterprise CMS features
      3. Understanding CMS platforms
    2. Understanding Piranha CMS
      1. Open source libraries and licensing
      2. Creating a Piranha CMS website
      3. Exploring a Piranha CMS website
      4. Editing site and page content
      5. Creating a new top-level page
      6. Creating a new child page
      7. Reviewing the blog archive
      8. Commenting on posts and pages
      9. Exploring authentication and authorization
      10. Exploring configuration
      11. Testing the new content
      12. Understanding routing
      13. Understanding media
      14. Understanding the application service
      15. Understanding content types
        1. Understanding component types
        2. Understanding standard fields
        3. Customizing the rich text editor
        4. Reviewing the Standard page type
        5. Reviewing the Standard archive and post types
      16. Understanding standard blocks
      17. Reviewing component types and standard blocks
    3. Defining components, content types, and templates
      1. Creating custom regions
      2. Creating an entity data model
      3. Creating custom page types
      4. Creating custom view models
      5. Defining custom content templates for content types
      6. Configuring startup and importing from a database
      7. Learning how to create content using the project template
    4. Testing the Northwind CMS website
      1. Uploading images and creating the catalog root
      2. Importing category and product content
      3. Managing catalog content
      4. Reviewing how Piranha stores content
    5. Practicing and exploring
      1. Exercise 17.1 – Test your knowledge
      2. Exercise 17.2 – Practice defining a block type for rendering YouTube videos
      3. Exercise 17.3 – Explore topics
    6. Summary
  19. Building and Consuming Web Services
    1. Building web services using the ASP.NET Core Web API
      1. Understanding web service acronyms
      2. Creating an ASP.NET Core Web API project
      3. Reviewing the web service's functionality
      4. Creating a web service for the Northwind database
      5. Creating data repositories for entities
      6. Implementing a Web API controller
      7. Configuring the customers repository and Web API controller
      8. Specifying problem details
      9. Controlling XML serialization
    2. Documenting and testing web services
      1. Testing GET requests using a browser
      2. Testing HTTP requests with the REST Client extension
      3. Understanding Swagger
      4. Testing requests with Swagger UI
    3. Consuming services using HTTP clients
      1. Understanding HttpClient
      2. Configuring HTTP clients using HttpClientFactory
      3. Getting customers as JSON in the controller
      4. Enabling Cross-Origin Resource Sharing
    4. Implementing advanced features
      1. Implementing a Health Check API
      2. Implementing Open API analyzers and conventions
      3. Implementing transient fault handling
      4. Understanding endpoint routing
      5. Configuring endpoint routing
      6. Adding security HTTP headers
      7. Securing web services
    5. Understanding other communication technologies
      1. Understanding Windows Communication Foundation (WCF)
      2. Understanding gRPC
    6. Practicing and exploring
      1. Exercise 18.1 – Test your knowledge
      2. Exercise 18.2 – Practice creating and deleting customers with HttpClient
      3. Exercise 18.3 – Explore topics
    7. Summary
  20. Building Intelligent Apps Using Machine Learning
    1. Understanding machine learning
      1. Understanding the machine learning lifecycle
      2. Understanding datasets for training and testing
      3. Understanding machine learning tasks
      4. Understanding Microsoft Azure Machine Learning
    2. Understanding ML.NET
      1. Understanding Infer.NET
      2. Understanding ML.NET learning pipelines
      3. Understanding model training concepts
      4. Understanding missing values and key types
      5. Understanding features and labels
    3. Making product recommendations
      1. Problem analysis
      2. Data gathering and processing
      3. Creating the NorthwindML website project
        1. Creating the data and view models
        2. Implementing the controller
        3. Training the recommendation models
        4. Implementing a shopping cart with recommendations
      4. Testing the product recommendations website
    4. Practicing and exploring
      1. Exercise 19.1 – Test your knowledge
      2. Exercise 19.2 – Practice with samples
      3. Exercise 19.3 – Explore topics
    5. Summary
  21. Building Web User Interfaces Using Blazor
    1. Understanding Blazor
      1. Understanding Blazor hosting models
      2. Understanding Blazor components
      3. What is the deal with Blazor and Razor?
      4. Comparing Blazor project templates
        1. Reviewing the Blazor Server project template
        2. Understanding CSS isolation
        3. Running the Blazor Server project template
        4. Reviewing the Blazor WebAssembly project template
    2. Building components using Blazor Server
      1. Defining and testing a simple component
      2. Getting entities into a component
      3. Abstracting a service for a Blazor component
      4. Using Blazor forms
        1. Defining forms using the EditForm component
        2. Navigating Blazor routes
        3. Building and using a customer form component
    3. Building components using Blazor WebAssembly
      1. Configuring the server for Blazor WebAssembly
      2. Configuring the client for Blazor WebAssembly
      3. Exploring Progressive Web App support
    4. Practicing and exploring
      1. Exercise 20.1 – Test your knowledge
      2. Exercise 20.2 – Practice creating a component
      3. Exercise 20.3 – Explore topics
    5. Summary
  22. Building Cross-Platform Mobile Apps
    1. Understanding XAML
      1. Simplifying code using XAML
      2. Choosing common controls
      3. Understanding markup extensions
    2. Understanding Xamarin and Xamarin.Forms
      1. How Xamarin.Forms extends Xamarin
      2. Development tools for mobile first, cloud first
      3. Mobile platform market share
      4. Understanding additional functionality
        1. Understanding the INotificationPropertyChanged interface
        2. Understanding dependency services
      5. Understanding Xamarin.Forms user interface components
        1. Understanding the ContentPage view
        2. Understanding the Entry and Editor controls
        3. Understanding the ListView control
    3. Building mobile apps using Xamarin.Forms
      1. Adding Android SDKs
      2. Creating a Xamarin.Forms solution
      3. Creating an entity model with two-way data binding
      4. Creating a component for dialing phone numbers
      5. Creating views for the customers list and customer details
        1. Implementing the customer list view
        2. Implementing the customer detail view
        3. Setting the main page for the mobile app
      6. Testing the mobile app
    4. Consuming a web service from a mobile app
      1. Configuring the web service to allow insecure requests
      2. Configuring the iOS app to allow insecure connections
      3. Configuring the Android app to allow insecure connections
      4. Adding NuGet packages for consuming a web service
      5. Getting customers from the web service
    5. Practicing and exploring
      1. Exercise 21.1 – Test your knowledge
      2. Exercise 21.2 – Explore topics
    6. Summary
    7. Epilogue
  23. Index

Product information

  • Title: C# 9 and .NET 5 – Modern Cross-Platform Development - Fifth Edition
  • Author(s): Mark J. Price
  • Release date: November 2020
  • Publisher(s): Packt Publishing
  • ISBN: 9781800568105