ASP.NET Core in Action, Second Edition
Andrew Lock
  • MEAP began May 2020
  • Publication in Spring 2021 (estimated)
  • ISBN 9781617298301
  • 700 pages (estimated)
  • printed in black & white
free previous edition eBook included
An eBook copy of the previous edition of this book is included at no additional cost. It will be automatically added to your Manning Bookshelf within 24 hours of purchase.

If you want a great comprehensive book to help you learn ASP.Net Core 3, look no further.

Tanya Wilke
Fully updated to ASP.NET 3.1, ASP.NET Core in Action, Second Edition is a hands-on primer to building cross-platform web applications with your C# and .NET skills. Even if you’ve never worked with ASP.NET you’ll start creating productive cross-platform web apps fast. And don’t worry about late-breaking changes to ASP.NET Core. With this Manning Early Access Program edition you’ll get updates right up until it ships to the printer, so you’re always working with the latest version of the technology.

About the Technology

ASP.NET Core is a highly flexible, high performance cross platform web framework that’s entirely free and open source. ASP.NET Core developers enjoy choice without compromise, benefiting from both a mature, well-supported stack and the freedom to develop and deploy from and onto any cloud or on-prem platform. Now in version 3.1, the latest version of ASP.NET Core includes powerful new additions for building server-side apps and background services.

About the book

ASP.NET Core in Action, Second Edition opens up the world of cross-platform web development with ASP.NET Core. You’ll start with a crash course in .NET Core, immediately cutting the cord between ASP.NET and Windows. Then, you’ll begin to build amazing web applications step by step, systematically adding essential features like logins, configuration, dependency injection, and custom components. Along the way, you’ll mix in important process steps like testing, multiplatform deployment, and security. Fully updated to version 3.1 and primed for live updating to .NET 5, this new edition fully covers new features such as server-side apps with Razor Pages, and the new ASP.NET Core hosting paradigm.
Table of Contents detailed table of contents

PART 1 Building your first applications

1 Getting started with ASP.NET Core

1.1 An introduction to ASP.NET Core

1.1.1 Using a web framework

1.1.2 The benefits and limitations of ASP.NET

1.1.3 What is ASP.NET Core?

1.2 When to choose ASP.NET Core

1.2.1 What type of applications can you build?

1.2.2 If you’re new to .NET development

1.2.3 If you’re a .NET Framework developer creating a new application

1.2.4 Converting an existing ASP.NET application to ASP.NET Core

1.3 How does ASP.NET Core work?

1.3.1 How does an HTTP web request work?

1.3.2 How does ASP.NET Core process a request?

1.4 What you will learn in this book

1.5 Summary

2 Your first application

2.1 A brief overview of an ASP.NET Core application

2.2 Creating your first ASP.NET Core application

2.2.1 Using a template to get started

2.2.2 Building the application

2.3 Running the web application

2.4 Understanding the project layout

2.5 The csproj project file: defining your dependencies

2.6 The Program class: building a web host

2.7 The Startup class: configuring your application

2.7.1 Adding and configuring services

2.7.2 Defining how requests are handled with middleware

2.8 Generating responses with Razor Pages

2.8.1 Generating HTML with Razor Pages

2.8.2 Handling request logic with PageModels and handlers

2.9 Summary

3 Handling requests with the middleware pipeline

3.1 What is middleware?

3.2 Combining middleware in a pipeline

3.2.1 Simple pipeline scenario 1: a holding page

3.2.2 Simple pipeline scenario 2: Handling static files

3.2.3 Simple pipeline scenario 3: A Razor Pages application

3.3 Handling errors using middleware

3.3.1 Viewing exceptions in development: DeveloperExceptionPage

3.3.2 Handling exceptions in production: ExceptionHandlerMiddleware

3.3.3 Handling other errors: StatusCodePagesMiddleware

3.3.4 Error handling middleware and Web APIs

3.4 Summary

4 Creating a web site with Razor Pages

4.1 An introduction to Razor Pages

4.1.1 Exploring a typical Razor Page

4.1.2 The MVC design pattern

4.1.3 Applying the MVC design pattern to Razor Pages

4.1.4 Adding Razor Pages to your application

4.2 Razor Pages vs MVC in ASP.NET Core

4.2.1 MVC controllers in ASP.NET Core

4.2.2 The benefits of Razor Pages

4.2.3 When to choose MVC controllers over Razor Pages

4.3 Razor Pages and page handlers

4.3.1 Accepting parameters to page handlers

4.3.2 Returning responses with ActionResults

4.4 Summary

5 Mapping URLs to Razor Pages using routing

5.1 What is routing?

5.2 Routing in ASP.NET Core

5.2.1 Using endpoint routing in ASP.NET Core

5.2.2 Convention-based routing vs attribute routing

5.2.3 Routing to Razor Pages

5.3 Customizing Razor Page route templates

5.3.1 Adding a segment to a Razor Page route template

5.3.2 Replacing a Razor Page route template completely

5.4 Exploring the route template syntax

5.4.1 Using optional and default values

5.4.2 Adding additional constraints to route parameters

5.4.3 Matching arbitrary URLs with the catch-all parameter

5.5 Generating URLs from route parameters

5.5.1 Generating URLs for a Razor Page

5.5.2 Generating URLs for an MVC controller

5.5.3 Generating URLs with ActionResults

5.5.4 Generating URLs from other parts of your application

5.6 Selecting a page handler to invoke

5.7 Customizing conventions with Razor Pages

5.8 Summary

6 The binding model: retrieving and validating user input

6.1 Understanding the models in Razor Pages and MVC

6.2 From request to model: making the request useful

6.2.1 Binding simple types

6.2.2 Binding complex types

6.2.3 Choosing a binding source

6.3 Handling user input with model validation

6.3.1 The need for validation

6.3.2 Using DataAnnotations attributes for validation

6.3.3 Validating on the server for safety

6.3.4 Validating on the client for user experience

6.4 Organizing your binding models in Razor Pages

6.5 Summary

7 Rendering HTML using Razor views

8 Building forms with Tag Helpers

9 Creating a Web API for mobile and client applications using MVC

PART 2 Building complete applications

10 Service configuration with dependency injection

11 Configuring an ASP.NET Core application

12 Saving data with Entity Framework Core

13 The MVC filter pipeline

14 Authentication: adding users to your application with Identity

15 Authorisation: Securing your application

16 Publishing and deploying your application

PART 3 Extending your application

17 Monitoring and troubleshooting errors with logging

18 Improving your application’s security

19 Building custom components

20 Building background tasks and backend services

21 Testing your application

Appendixes

Appendix A: Installing and configuring your development environment

Appendix B: Getting to grips with .NET versioning

  • Routing is the process of mapping an incoming request URL to a Razor Page that will execute to generate a response. You can use routing to decouple your URLs from the files in your project and to have multiple URLs map to the same Razor Page.

  • ASP.NET Core uses two pieces of middleware for routing. The EndpointRoutingMiddleware is added in Startup.cs by calling UseRouting() and the EndpointMiddleware is added by calling UseEndpoints().

  • The EndpointRoutingMidleware selects which endpoint should be executed by using routing to match the request URL. The EndpointMiddleware executes the endpoint.

  • Any middleware placed between the calls to UseRouting() and UseEndpoints() can tell which endpoint will be executed for the request.

  • Route templates define the structure of known URLs in your application. They’re strings with placeholders for variables that can contain optional values and map to Razor Pages or to MVC controller actions.

  • Route parameters are variable values extracted from a request’s URL.

  • Route parameters can be optional and can have default values used when they’re missing.

  • Route parameters can have constraints that restrict the possible values allowed. If a route parameter doesn’t match its constraints, the route isn’t considered a match.

  • Don’t use route constraints as general input validators. Use them to disambiguate between two similar routes.

  • Use a catch-all parameter to capture the remainder of a URL into a route value.

  • You can use the routing infrastructure to generate internal URLs for your application.

  • The IUrlHelper can be used to generate URLs as a string based on an action name or Razor Page.

  • You can use the RedirectToAction and RedirectToPage methods to generate URLs while also generating a redirect response.

  • The LinkGenerator can be used to generate URLs from other services in your application, where you don’t have access to an HttpContext object.

  • When a Razor Page is executed, a single page handler is invoked based on the HTTP verb of the request, and the value of the handler route value.

  • If there is no page handler for a request, an implicit page handler is used that renders the Razor view.

  • You can control the routing conventions used by ASP.NET Core by configuring the RouteOptions object, for example to force all URLs to be lowercase, or to always append a trailing slash.

  • You can add additional routing conventions for Razor Pages by calling AddRazorPagesOptions() after AddRazorPages() in Startup.cs. These conventions can control how route parameters are displayed or can add additional route templates for specific Razor Pages.

  • Where possible, avoid customizing the route templates for a Razor Page and rely on the conventions instead.

6 The binding model: retrieving and validating user input

7 Rendering HTML using Razor views

8 Building forms with Tag Helpers

9 Creating a Web API for mobile and client applications using MVC

PART 2 Building complete applications

10 Service configuration with dependency injection

11 Configuring an ASP.NET Core application

12 Saving data with Entity Framework Core

13 The MVC filter pipeline

14 Authentication: adding users to your application with Identity

15 Authorisation: Securing your application

16 Publishing and deploying your application

PART 3 Extending your application

17 Monitoring and troubleshooting errors with logging

18 Improving your application’s security

19 Building custom components

20 Building background tasks and backend services

21 Testing your application

Appendixes

Appendix C: Installing and configuring your development environment

Appendix D: Getting to grips with .NET versioning

What's inside

  • Covers ASP.NET Core 3.1
  • Dynamic page generation with the Razor templating engine
  • Server-side apps with Razor Pages
  • Authentication and authorization
  • Unit tests and integration tests for ASP.NET Core apps
  • Create a Web API for serving JSON to client-side applications
  • Developing ASP.NET Core apps for non-Windows servers

About the reader

Readers need intermediate experience with C# or a similar language.

About the author

Andrew Lock is a Microsoft MVP who has been working with ASP.NET Core since before the first release. He has a PhD in digital image processing, and has been developing professionally using .NET for the last 10 years.

placing your order...

Don't refresh or navigate away from the page.
Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
print book $35.99 $59.99 pBook + eBook + liveBook
includes previous edition eBook
Additional shipping charges may apply
ASP.NET Core in Action, Second Edition (print book) added to cart
continue shopping
go to cart

eBook $33.59 $47.99 3 formats + liveBook
includes previous edition eBook
ASP.NET Core in Action, Second Edition (eBook) added to cart
continue shopping
go to cart

Prices displayed in rupees will be charged in USD when you check out.

FREE domestic shipping on three or more pBooks