ASP.NET Core Razor Pages in Action
Razor Pages lets you build, configure, and deploy amazing dynamic ASP.NET websites with ease.

In ASP.NET Core Razor Pages in Action you will learn:

Building, configuring, and publishing a data-driven website
Creating a complete web application step-by-step
Forms for collecting and processing user data
Connecting to databases from a Razor Page
Protecting areas of a Razor Page from unauthorized access with ASP.NET Identity
Using Object Relational Mapping tools to work with data in Razor Pages applications
Generating CRUD pages using scaffolding gestures
Generating and sending email from your web application

ASP.NET Core Razor Pages in Action teaches you to develop dynamic websites using the powerful Razor Pages framework, .NET 6, and ASP.NET. Razor Pages generates HTML on the server, and is the perfect choice for eCommerce sites, intranet services, content management systems, and other apps that require reliability. In this book, you’ll use Razor Pages to build a complete application for booking city breaks, learning to iterate amazing new features chapter-by-chapter. You’ll even learn how to enhance your web applications with the huge ecosystem of C# libraries, and how to locate the perfect tool for your task using centralized repositories.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the technology
Simplify ASP.NET web development with Razor Pages! Razor Pages provides a cohesive page-based organization layer for application components like routes and actions. It’s page-centric approach means you spend less dev time switching between the controller, model, and view files, as compared to a traditional MVC approach.

About the book
ASP.NET Core Razor Pages in Action teaches you how to use Razor Pages to code and scale dynamic ASP.NET Core websites. You’ll learn a new feature in every chapter as you build an interesting vacation-booking application. As your app grows, you’ll be amazed how Razor Pages accelerates essential tasks like form creation, data processing, testing, and deployment.

What's inside

Securing your applications from unauthorized access
Using object-relational mapping tools to work with data
Generating and sending email from a web application
Enhance your web apps with C# libraries

About the reader
For web developers familiar with C# programming.

About the author
Mike Brind is an 11-time recipient of the Microsoft Most Valuable Professional (MVP) award for ASP.NET.

Table of Contents
1 Getting started with Razor Pages
2 Building your first application
3 Working with Razor Pages
4 Matching URLs to Razor Pages with routing
5 Working with forms: Model binding
6 Working with forms: Tag helpers
7 Using dependency injection to manage services
8 Working with data
9 Managing users with authentication
10 Controlling access with authorization
11 Client-side technologies and AJAX
12 Troubleshooting your application
13 Protecting your application against external attacks
14 Configuring and publishing your application
1140862198
ASP.NET Core Razor Pages in Action
Razor Pages lets you build, configure, and deploy amazing dynamic ASP.NET websites with ease.

In ASP.NET Core Razor Pages in Action you will learn:

Building, configuring, and publishing a data-driven website
Creating a complete web application step-by-step
Forms for collecting and processing user data
Connecting to databases from a Razor Page
Protecting areas of a Razor Page from unauthorized access with ASP.NET Identity
Using Object Relational Mapping tools to work with data in Razor Pages applications
Generating CRUD pages using scaffolding gestures
Generating and sending email from your web application

ASP.NET Core Razor Pages in Action teaches you to develop dynamic websites using the powerful Razor Pages framework, .NET 6, and ASP.NET. Razor Pages generates HTML on the server, and is the perfect choice for eCommerce sites, intranet services, content management systems, and other apps that require reliability. In this book, you’ll use Razor Pages to build a complete application for booking city breaks, learning to iterate amazing new features chapter-by-chapter. You’ll even learn how to enhance your web applications with the huge ecosystem of C# libraries, and how to locate the perfect tool for your task using centralized repositories.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the technology
Simplify ASP.NET web development with Razor Pages! Razor Pages provides a cohesive page-based organization layer for application components like routes and actions. It’s page-centric approach means you spend less dev time switching between the controller, model, and view files, as compared to a traditional MVC approach.

About the book
ASP.NET Core Razor Pages in Action teaches you how to use Razor Pages to code and scale dynamic ASP.NET Core websites. You’ll learn a new feature in every chapter as you build an interesting vacation-booking application. As your app grows, you’ll be amazed how Razor Pages accelerates essential tasks like form creation, data processing, testing, and deployment.

What's inside

Securing your applications from unauthorized access
Using object-relational mapping tools to work with data
Generating and sending email from a web application
Enhance your web apps with C# libraries

About the reader
For web developers familiar with C# programming.

About the author
Mike Brind is an 11-time recipient of the Microsoft Most Valuable Professional (MVP) award for ASP.NET.

Table of Contents
1 Getting started with Razor Pages
2 Building your first application
3 Working with Razor Pages
4 Matching URLs to Razor Pages with routing
5 Working with forms: Model binding
6 Working with forms: Tag helpers
7 Using dependency injection to manage services
8 Working with data
9 Managing users with authentication
10 Controlling access with authorization
11 Client-side technologies and AJAX
12 Troubleshooting your application
13 Protecting your application against external attacks
14 Configuring and publishing your application
59.99 In Stock
ASP.NET Core Razor Pages in Action

ASP.NET Core Razor Pages in Action

by Mike Brind
ASP.NET Core Razor Pages in Action

ASP.NET Core Razor Pages in Action

by Mike Brind

Paperback

$59.99 
  • SHIP THIS ITEM
    In stock. Ships in 1-2 days.
  • PICK UP IN STORE

    Your local store may have stock of this item.

Related collections and offers


Overview

Razor Pages lets you build, configure, and deploy amazing dynamic ASP.NET websites with ease.

In ASP.NET Core Razor Pages in Action you will learn:

Building, configuring, and publishing a data-driven website
Creating a complete web application step-by-step
Forms for collecting and processing user data
Connecting to databases from a Razor Page
Protecting areas of a Razor Page from unauthorized access with ASP.NET Identity
Using Object Relational Mapping tools to work with data in Razor Pages applications
Generating CRUD pages using scaffolding gestures
Generating and sending email from your web application

ASP.NET Core Razor Pages in Action teaches you to develop dynamic websites using the powerful Razor Pages framework, .NET 6, and ASP.NET. Razor Pages generates HTML on the server, and is the perfect choice for eCommerce sites, intranet services, content management systems, and other apps that require reliability. In this book, you’ll use Razor Pages to build a complete application for booking city breaks, learning to iterate amazing new features chapter-by-chapter. You’ll even learn how to enhance your web applications with the huge ecosystem of C# libraries, and how to locate the perfect tool for your task using centralized repositories.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the technology
Simplify ASP.NET web development with Razor Pages! Razor Pages provides a cohesive page-based organization layer for application components like routes and actions. It’s page-centric approach means you spend less dev time switching between the controller, model, and view files, as compared to a traditional MVC approach.

About the book
ASP.NET Core Razor Pages in Action teaches you how to use Razor Pages to code and scale dynamic ASP.NET Core websites. You’ll learn a new feature in every chapter as you build an interesting vacation-booking application. As your app grows, you’ll be amazed how Razor Pages accelerates essential tasks like form creation, data processing, testing, and deployment.

What's inside

Securing your applications from unauthorized access
Using object-relational mapping tools to work with data
Generating and sending email from a web application
Enhance your web apps with C# libraries

About the reader
For web developers familiar with C# programming.

About the author
Mike Brind is an 11-time recipient of the Microsoft Most Valuable Professional (MVP) award for ASP.NET.

Table of Contents
1 Getting started with Razor Pages
2 Building your first application
3 Working with Razor Pages
4 Matching URLs to Razor Pages with routing
5 Working with forms: Model binding
6 Working with forms: Tag helpers
7 Using dependency injection to manage services
8 Working with data
9 Managing users with authentication
10 Controlling access with authorization
11 Client-side technologies and AJAX
12 Troubleshooting your application
13 Protecting your application against external attacks
14 Configuring and publishing your application

Product Details

ISBN-13: 9781617299988
Publisher: Manning
Publication date: 12/27/2022
Pages: 456
Product dimensions: 7.38(w) x 9.25(h) x 0.90(d)

About the Author

Mike Brind is an 11-time recipient of the Microsoft Most Valuable Professional (MVP) award for ASP.NET. He is a regular Razor Pages blogger and a moderator of the official ASP.NET forums.

Table of Contents

Preface ix

Acknowledgments xi

About this book xii

About the author xv

About the cover illustration xvi

1 Getting started with Razor Pages 1

1.1 What is Razor Pages? 2

Web development frameworks 2

Server-side frameworks 4

Cross-platform functionality 5

Open source 5

Using your existing knowledge 6

1.2 What can you do with Razor Pages? 6

1.3 The technologies that underpin Razor Pages 6

The ASP.NET Core MVC framework 7

Model-view-controller 7

The design goals of Razor Pages 9

1.4 When should you use Razor Pages? 10

1.5 Working with Razor Pages 11

How do you get Razor Pages? 11

Choosing a development environment 12

Choosing a database system 14

2 Building your first application 17

2.1 Creating your first website 18

Creating a website using Visual Studio 19

Creating a website using the command-line interface 20

Running the application 21

Adding a new page 23

Modifying to include dynamic content 25

Adding the page to the navigation 27

2.2 Exploring the project files 27

The WebApplication1.sln file 28

The WebApplication1.csproj file 28

The bin and obj folders 29

The Properties folder 29

The wwwroot folder 30

The Pages folder 30

The app-settings files 31

Program.cs 32

2.3 Understanding middleware 35

An HTTP refresher 35

The Http Context 38

The application request pipeline 39

Creating middleware 41

Middleware classes 45

3 Working with Razor Pages 50

3.1 Working with Razor syntax 51

Directives and code blocks 51

Rendering HTML with expressions 54

Control blocks in Razor 55

Rendering literal strings 57

Rendering literal HTML 57

3.2 Layout pages 62

Assigning the Layout property 64

Infecting optional content with sections 66

3.3 Reusable HTML with partial views, tag helpers, and view components 68

Partial views 68

Tag helpers 70

View components 72

3.4 The PageModel 72

Passing data to pages 73

The PageModel as a view model 75

The PageModel as a controller 78

4 Matching URLs to Razor Pages with routing 86

4.1 Routing basics 87

Route templates 89

4.2 Customizing route templates 91

Overriding routes 91

Route parameters 92

H Binding route data to handler parameters 94

Catchall parameters 96

Route constraints 96

Creating additional routes 100

Working with PageRouteModel conventions directly 101

4.3 Generating URLs 104

The anchor tag helper 104

Using the IUrlHelper to generate URLs 107

Generating redirect URLs from ActionResults 108

Customizing URL generation 109

Using parameter transformers to customize route and parameter value generation 110

5 Working with forms: Model binding 115

5.1 Forms basics 117

Using the post-redirect-get pattern 117

Accessing values from Request.Form 119

Accessing values from Request.Query 121

5.2 Model binding 124

Using model binding with handler parameters 124

Using model binding with public properties 125

Binding complex objects 127

Binding simple collections 132

Binding complex collections 134

5.3 Validating user input in Razor Pages 140

DataAnnotation attributes 140

Client-side validation 142

Server-side validation 146

Managing more complex validation with ModelState 147

Custom validation attributes 148

6 Working with forms: Tag helpers 152

6.1 The form and form action tag helpers 153

6.2 Input and label tag helpers 154

Understanding the input types 156

Using data annotation attributes to control presentation 160

Formatting the rendered date or time value 161

Using the Display Attribute to control labels 163

6.3 The select tag helper 164

Creating options 165

Binding multiple values 170

Working with OptGroups 173

Binding enumerations 175

6.4 Check boxes and radio controls 178

6.5 Uploading files 179

7 Using dependency injection to manage services 187

7.1 The reason for dependency injection 188

Single-responsibility principle 188

Loose coupling 192

Dependency inversion 193

Dependency injection 195

7.2 Inversion of control containers 195

Service registration 196

Service lifetimes 197

Captive dependencies 201

Other service registration options 202

Registering multiple implementations 203

7.3 Other ways to access registered services 205

View injection 205

Method injection 206

Directly from the service container with GetService and GetRequiredService 206

8 Working with data 209

8.1 What is Entity Framework Core? 210

Why choose EE Core? 210

How does EF Core work? 211

Managing relationships 213

Installing Entity Framework Core 215

Create, the context 216

Adding DbSets 217

Configuring the model 218

8.2 Migrations 219

Seed data 220

Adding migration tools 222

Creating and applying a migration 222

8.3 Querying data 224

Retrieving multiple records 224

Selecting single records 227

8.4 Scaffolding CRUD pages 231

Visual Studio scaffold instructions 232

Scaffolding from the command line 233

Working with the scaffolded pages 235

8.5 Creating, modifying, and deleting data 238

Modifying data 241

Deleting data 245

9 Managing users with authentication 252

9.1 Authentication basics 253

How authentication works 253

Adding simple authentication 254

9.2 ASP.NET Core Identity 259

Creating a user 260

Configuring the DbContext 261

Adding migration 262

9.3 Customizing Identity 265

Customizing Identity options 265

Customizing the user 268

Scaffolding and customizing the UI 269

Enabling email confirmation 277

Disabling UI features 281

10 Controlling access with authorization 283

10.1 Basic authorization in Razor Pages 284

Applying simple authorization 285

Allowing anonymous access 290

10.2 Working with roles 290

Viewing roles 291

Adding roles 292

Assigning roles to users 294

Using policies to apply role checks 296

10.3 Claims-based authorization 297

Adding claims to users 298

Using policies to enforce claims-based authorization 302

Using assertions for more complex requirements 303

Custom authorization requirements and handlers 304

Roles or claims? 308

10.4 Authorizing resources 309

Creating a requirement and a handler 310

Applying authorization to the UI 314

11 Client-side technologies and AJAX 317

11.1 Choosing your client-side technology 318

11.2 Calling page handlers from JavaScript 319

Using a partial page to return HTML 319

Posting to a page handier 324

Working with JsonResult 328

11.3 Minimal request-handling APIs 331

An example minimal API 332

Parameters in minimal APIs 333

Minimal API return types 335

11.4 CSS Isolation in Razor Pages 337

12 Troubleshooting your application 341

12.1 Exception management 343

The Developer Exception page 343

ExceptionHandlerMiddleware 345

12.2 StatusCodePages 347

Exploring WithRedirects 348

StatusCodePages WithReExecute 350

12.3 Logging 353

Logging basics 353

Log levels 354

Log categories 356

Using EventIds 357

Formatting the log message 358

Applying log filter rules 358

Custom email logger 360

Structured logging with Serilog 363

13 Protecting your application against external attacks 369

13.1 HTTPS 370

SSL/TLS certificates 371

Using HTFPS in development 372

Including HSTS in production 374

13.2 Broken access control 375

Incorrect security policies 375

Cross-site request forgery 376

13.3 Cryptographic failures 379

Plain-text passwords 379

Using the PasswordHasher without Identity UI 381

13.4 Injection attacks 384

SQL injection 384

Cross-site scripting 387

14 Configuring and publishing your application 391

14.1 Working with environments 392

Understanding and managing environments 392

Setting the environment 393

Registering services conditionally for each environment 395

The IHostEnvironment service 396

The environment tag helper 397

14.2 Application configuration 398

AppSettings.json 399

Accessing configuration settings programmatically by key 400

Strongly typed app settings 401

Using the options pattern 403

Binding directly to POCOs 403

Environments 404

14.3 Improving performance with caching 405

The cache tag helper 406

In-memory caching with IMemoryCache 409

14.4 Publishing your application 412

Self-contained and framework-dependent 412

Publishing using the CLI 413

Publishing using Visual Studio 414

Index 421

From the B&N Reads Blog

Customer Reviews