Pro ASP.NET Core MVC 2 -  Adam Freeman

Pro ASP.NET Core MVC 2 (eBook)

(Autor)

eBook Download: PDF | EPUB
2017 | 7th ed.
XXIX, 1017 Seiten
Apress (Verlag)
978-1-4842-3150-0 (ISBN)
58,84 € inkl. MwSt
Systemvoraussetzungen
55,54 € inkl. MwSt
Systemvoraussetzungen
  • Download sofort lieferbar
  • Zahlungsarten anzeigen

Now in its 7th edition, the best selling book on MVC is updated for ASP.NET Core MVC 2. It contains detailed explanations of the Core MVC functionality which enables developers to produce leaner, cloud optimized and mobile-ready applications for the .NET platform. This book puts ASP.NET Core MVC into context and dives deep into the tools and techniques required to build modern, cloud optimized extensible web applications. All the new MVC features are described in detail and the author explains how best to apply them to both new and existing projects.

The ASP.NET Core MVC Framework is the latest evolution of Microsoft's ASP.NET web platform, built on a completely new foundation. It represents a fundamental change to how Microsoft constructs and deploys web frameworks and is free of the legacy of earlier technologies such as Web Forms. ASP.NET Core MVC provides a 'host agnostic' framework and a high-productivity programming model that promotes cleaner code architecture, test-driven development, and powerful extensibility.

Best-selling author Adam Freeman has thoroughly revised this market-leading book and explains how to get the most from ASP.NET Core MVC. He starts with the nuts-and-bolts and shows you everything through to advanced features, going in-depth to give you the knowledge you need. The book includes a fully worked case study of a functioning web application that readers can use as a template for their own projects.

What's New in This Edition

  • Fully updated for Visual Studio 2017, C# 7 and .NET Core 2
  • Coverage of new features such as view filters
  • Wider platform and tooling coverage than ever before, with more on Visual Studio Code and working with .NET Core on non-Windows platforms
  • Docker-based application deployment

What You Will Learn

  • Gain a solid architectural understanding of ASP.NET Core MVC
  • Explore the entire ASP.NET MVC Framework as a cohesive whole
  • See how MVC and test-driven development work in action
  • Learn what's new in ASP.NET Core MVC 2 and how best to apply these new features to your own work
  • See how to create RESTful web services and Single Page Applications
  • Build on your existing knowledge of previous MVC releases to get up and running with the new programming model quickly and effectively

Who This Book Is For

This book is for web developers with a basic knowledge of ASP.NET and C# who want to incorporate the latest improvements and functionality in the ASP.NET Core MVC 2 Framework.




Adam Freeman is an experienced IT professional who has held senior positions in a range of companies, most recently serving as chief technology officer and chief operating officer of a global bank. Now retired, he spends his time writing and long-distance running.
Now in its 7th edition, the best selling book on MVC is updated for ASP.NET Core MVC 2. It contains detailed explanations of the Core MVC functionality which enables developers to produce leaner, cloud optimized and mobile-ready applications for the .NET platform. This book puts ASP.NET Core MVC into context and dives deep into the tools and techniques required to build modern, cloud optimized extensible web applications. All the new MVC features are described in detail and the author explains how best to apply them to both new and existing projects.The ASP.NET Core MVC Framework is the latest evolution of Microsoft's ASP.NET web platform, built on a completely new foundation. It represents a fundamental change to how Microsoft constructs and deploys web frameworks and is free of the legacy of earlier technologies such as Web Forms. ASP.NET Core MVC provides a "e;host agnostic"e; framework and a high-productivity programming model that promotes cleaner code architecture, test-driven development, and powerful extensibility.Best-selling author Adam Freeman has thoroughly revised this market-leading book and explains how to get the most from ASP.NET Core MVC. He starts with the nuts-and-bolts and shows you everything through to advanced features, going in-depth to give you the knowledge you need. The book includes a fully worked case study of a functioning web application that readers can use as a template for their own projects.What's New in This EditionFully updated for Visual Studio 2017, C# 7 and .NET Core 2Coverage of new features such as view filtersWider platform and tooling coverage than ever before, with more on Visual Studio Code and working with .NET Core on non-Windows platformsDocker-based application deploymentWhat You Will LearnGain a solid architectural understanding of ASP.NET Core MVCExplorethe entire ASP.NET MVC Framework as a cohesive wholeSee how MVC and test-driven development work in actionLearn what's new in ASP.NET Core MVC 2 and how best to apply these new features to your own workSee how to create RESTful web services and Single Page ApplicationsBuild on your existing knowledge of previous MVC releases to get up and running with the new programming model quickly and effectivelyWho This Book Is ForThis book is for web developers with a basic knowledge of ASP.NET and C# who want to incorporate the latest improvements and functionality in the ASP.NET Core MVC 2 Framework.

Adam Freeman is an experienced IT professional who has held senior positions in a range of companies, most recently serving as chief technology officer and chief operating officer of a global bank. Now retired, he spends his time writing and long-distance running.

Contents at a Glance 5
Contents 7
About the Author 27
About the Technical Reviewer 28
Part I: Introducing ASP.NET Core MVC 2 29
Chapter 1: ASP .NET Core MVC in Context 30
Understanding the History of ASP.NET Core MVC 30
ASP.NET Web Forms 31
What Was Wrong with ASP.NET Web Forms? 31
The Original MVC Framework 32
What Was Wrong with the Original MVC Framework? 32
Understanding ASP.NET Core 32
What’s New in ASP.NET Core MVC 2 33
Key Benefits of ASP.NET Core MVC 33
MVC Architecture 33
Extensibility 34
Tight Control over HTML and HTTP 34
Testability 34
Powerful Routing System 35
Modern API 35
Cross-Platform 35
ASP.NET Core MVC Is Open Source 36
What Do I Need to Know? 36
What Is the Structure of This Book? 36
Part 1: Introducing ASP.NET Core MVC 36
Part 2: ASP.NET Core MVC in Detail 36
Where Can You Get the Example Code? 36
Where Can You Get Corrections for This Book? 37
Contacting the Author 37
Summary 37
Chapter 2: Your First MVC Application 38
Installing Visual Studio 38
Installing the .NET Core 2.0 SDK 39
Creating a New ASP.NET Core MVC Project 40
Adding the Controller 44
Understanding Routes 47
Rendering Web Pages 47
Creating and Rendering a View 47
Adding Dynamic Output 50
Creating a Simple Data-Entry Application 52
Setting the Scene 52
Designing a Data Model 53
Creating a Second Action and a Strongly Typed View 54
Linking Action Methods 56
Building the Form 57
Receiving Form Data 59
Using Model Binding 60
Storing Responses 61
Displaying the Responses 64
Adding Validation 66
Highlighting Invalid Fields 70
Styling the Content 72
Styling the Welcome View 72
Styling the RsvpForm View 74
Styling the Thanks View 76
Styling the List View 77
Summary 78
Chapter 3: The MVC Pattern, Projects, and Conventions 79
The History of MVC 79
Understanding the MVC Pattern 79
Understanding Models 79
Understanding Controllers 80
Understanding Views 81
The ASP.NET Implementation of MVC 81
Comparing MVC to Other Patterns 82
Understanding the Smart UI Pattern 82
Understanding the Model-View Architecture 83
Understanding Classic Three-Tier Architecture 84
Understanding Variations on MVC 85
Understanding the Model-View-Presenter Pattern 85
Understanding the Model-View-View Model Pattern 85
Understanding ASP.NET Core MVC Projects 86
Creating the Project 86
Understanding MVC Conventions 89
Following Conventions for Controller Classes 90
Following Conventions for Views 90
Following Conventions for Layouts 91
Summary 91
Chapter 4: Essential C# Features 92
Preparing the Example Project 93
Enabling ASP.NET Core MVC 94
Creating the MVC Application Components 95
Creating the Model 95
Creating the Controller and View 96
Using the Null Conditional Operator 98
Chaining the Null Conditional Operator 99
Combining the Conditional and Coalescing Operators 100
Using Automatically Implemented Properties 101
Using Auto-Implemented Property Initializers 102
Creating Read-Only Automatically Implemented Properties 103
Using String Interpolation 104
Using Object and Collection Initializers 105
Using an Index Initializer 107
Pattern Matching 108
Pattern Matching in Switch Statements 109
Using Extension Methods 110
Applying Extension Methods to an Interface 111
Creating Filtering Extension Methods 113
Using Lambda Expressions 115
Defining Functions 116
Using Lambda Expression Methods and Properties 119
Using Type Inference and Anonymous Types 121
Using Anonymous Types 122
Using Asynchronous Methods 124
Working with Tasks Directly 124
Applying the async and await Keywords 126
Getting Names 127
Summary 129
Chapter 5: Working with Razor 130
Preparing the Example Project 131
Defining the Model 132
Creating the Controller 132
Creating the View 133
Working with the Model Object 134
Using View Imports 136
Working with Layouts 137
Creating the Layout 138
Applying a Layout 140
Using a View Start File 141
Using Razor Expressions 143
Inserting Data Values 144
Setting Attribute Values 146
Using Conditional Statements 147
Enumerating Arrays and Collections 149
Summary 151
Chapter 6: Working with Visual Studio 152
Preparing the Example Project 152
Creating the Model 153
Creating the Controller and View 154
Managing Software Packages 156
Understanding NuGet 156
Understanding the NuGet Packages List and Location 157
Understanding Bower 158
Understanding the Bower Packages List 158
Updating the Bootstrap Package 162
Understanding Iterative Development 162
Making Changes to Razor Views 163
Making Changes to C# Classes 164
Compiling Classes Automatically 164
Enabling Developer Exception Pages 166
Using the Debugger 167
Setting a Breakpoint 168
Viewing Data Values in the Code Editor 169
Using the Locals Window 171
Using Browser Link 172
Setting Up Browser Link 172
Using Browser Link 173
Using Multiple Browsers 175
Preparing JavaScript and CSS for Deployment 177
Enabling Static Content Delivery 178
Adding Static Content to the Project 178
Updating the View 181
Bundling and Minifying in MVC Applications 182
Installing the Visual Studio Extension 182
Bundling and Minifying Files 183
Summary 186
Chapter 7: Unit Testing MVC Applications 187
Preparing the Example Project 188
Enabling the Built-in Tag Helpers 188
Adding Actions to the Controller 188
Creating the Data Entry Form 189
Updating the Index View 190
Unit Testing MVC Applications 191
Creating a Unit Test Project 192
Removing the Default Test Class 193
Creating the Project Reference 193
Writing and Running Unit Tests 193
Running Tests with the Test Explorer 196
Isolating Components for Unit Testing 198
Isolating a Component 199
Improving Unit Tests 206
Parameterizing a Unit Test 206
Getting Test Data from a Method or Property 207
Improving Fake Implementations 210
Adding a Mocking Framework 211
Creating a Mock Object 213
Summary 215
Chapter 8: SportsStore: A Real Application 216
Getting Started 217
Creating the MVC Project 217
Creating the Folder Structure 218
Configuring the Application 219
Creating the Unit Test Project 221
Checking and Running the Application 222
Starting the Domain Model 223
Creating a Repository 224
Creating a Fake Repository 225
Registering the Repository Service 225
Displaying a List of Products 226
Adding a Controller 227
Adding and Configuring the View 228
Setting the Default Route 230
Running the Application 231
Preparing a Database 231
Installing the Entity Framework Core Tools Package 232
Creating the Database Classes 233
Creating the Repository Class 233
Defining the Connection String 234
Configuring the Application 235
Disabling Scope Verification 236
Creating the Database Migration 237
Creating the Seed Data 238
Adding Pagination 241
Displaying Page Links 243
Adding the View Model 243
Adding the Tag Helper Class 244
Adding the View Model Data 247
Displaying the Page Links 250
Improving the URLs 252
Styling the Content 254
Installing the Bootstrap Package 254
Applying Bootstrap Styles to the Layout 255
Creating a Partial View 258
Summary 259
Chapter 9: SportsStore: Navigation 260
Adding Navigation Controls 260
Filtering the Product List 260
Refining the URL Scheme 265
Building a Category Navigation Menu 269
Creating the Navigation View Component 269
Generating Category Lists 270
Creating the View 272
Highlighting the Current Category 273
Correcting the Page Count 276
Building the Shopping Cart 280
Defining the Cart Model 280
Adding the Add to Cart Buttons 284
Enabling Sessions 286
Implementing the Cart Controller 287
Defining Session State Extension Methods 288
Displaying the Contents of the Cart 289
Summary 293
Chapter 10: SportsStore: Completing the Cart 294
Refining the Cart Model with a Service 294
Creating a Storage-Aware Cart Class 294
Registering the Service 295
Simplifying the Cart Controller 296
Completing the Cart Functionality 297
Removing Items from the Cart 297
Adding the Cart Summary Widget 299
Adding the Font Awesome Package 299
Creating the View Component Class and View 300
Submitting Orders 302
Creating the Model Class 302
Adding the Checkout Process 303
Implementing Order Processing 307
Extending the Database 307
Creating the Order Repository 308
Completing the Order Controller 310
Displaying Validation Errors 313
Displaying a Summary Page 315
Summary 316
Chapter 11: SportsStore: Administration 317
Managing Orders 317
Enhancing the Model 317
Adding the Actions and View 318
Adding Catalog Management 321
Creating a CRUD Controller 322
Implementing the List View 324
Editing Products 325
Creating the Edit Action Method 326
Creating the Edit View 327
Updating the Product Repository 329
Handling Edit POST Requests 331
Displaying a Confirmation Message 333
Adding Model Validation 334
Enabling Client-Side Validation 337
Creating New Products 339
Deleting Products 340
Summary 344
Chapter 12: SportsStore: Security and Deployment 345
Securing the Administration Features 345
Creating the Identity Database 345
Creating the Context Class 345
Defining the Connection String 346
Configuring the Application 347
Creating and Applying the Database Migration 348
Defining the Seed Data 348
Applying a Basic Authorization Policy 350
Creating the Account Controller and Views 352
Testing the Security Policy 356
Deploying the Application 356
Creating the Databases 356
Opening Firewall Access for Configuration 357
Getting the Connection Strings 357
Preparing the Application 358
Creating the Error Controller and View 358
Defining the Production Database Settings 359
Configuring the Application 360
Applying the Database Migrations 362
Managing Database Seeding 362
Seeding Identity Data 363
Seeding the Product Data 364
Deploying the Application 366
Summary 370
Chapter 13: Working with Visual Studio Code 371
Setting Up the Development Environment 371
Installing Node.js 371
Installing Node.js on Windows 372
Installing Node.js on macOS 372
Installing Node.js on Linux 372
Checking the Node Installation 373
Installing Git 373
Installing Git on Windows or macOS 373
Installing Git on Linux 373
Checking the Git Installation 373
Installing Bower 374
Installing .NET Core 374
Installing .NET Core on Windows and macOS 374
Installing .NET Core on Linux 374
Checking the .NET Core Installation 375
Installing Visual Studio Code 375
Installing Visual Studio Code on Windows 375
Installing Visual Studio Code on macOS 375
Installing Visual Studio Code on Linux 376
Checking the Visual Studio Code Installation 376
Installing the Visual Studio Code C# Extension 377
Creating an ASP.NET Core Project 377
Preparing the Project with Visual Studio Code 378
Managing Client-Side Packages 379
Configuring the Application 381
Building and Running the Project 381
Re-creating the PartyInvites Application 382
Creating the Model and Repository 382
Creating the Database 386
Adding the Database Package 387
Creating and Applying the Database Migration 387
Creating the Controllers and Views 388
Unit Testing in Visual Studio Code 392
Creating a Unit Test 393
Running Tests 393
Summary 394
Part II: ASP.NET Core MVC 2 in Detail 395
Chapter 14: Configuring Applications 396
Preparing the Example Project 397
Configuring the Project 399
Adding Packages to the Project 400
Adding Tools Packages to the Project 402
Understanding the Program Class 403
Digging into the Configuration Detail 403
Understanding the Startup Class 407
Understanding ASP.NET Services 409
Understanding the Built-In MVC Services 411
Understanding ASP.NET Middleware 412
Creating Content-Generating Middleware 412
Using Services in Middleware 414
Creating Short-Circuiting Middleware 415
Creating Request-Editing Middleware 417
Creating Response-Editing Middleware 419
Understanding How the Configure Method Is Invoked 421
Using the Application Builder 422
Using the Hosting Environment 423
Adding the Remaining Middleware Components 426
Enabling Exception Handling 426
Enabling Browser Link 428
Enabling Static Content 429
Configuring the Application 430
Creating the JSON Configuration File 432
Using Configuration Data 434
Configuring Logging 436
Understanding the Logging Configuration Data 437
Creating Custom Log Messages 439
Configuring Dependency Injection 440
Configuring MVC Services 441
Dealing with Complex Configurations 443
Creating Different External Configuration Files 443
Creating Different Configuration Methods 445
Creating Different Configuration Classes 446
Summary 448
Chapter 15: URL Routing 449
Preparing the Example Project 450
Creating the Model Class 451
Creating the Example Controllers 451
Creating the View 452
Introducing URL Patterns 454
Creating and Registering a Simple Route 455
Defining Default Values 457
Defining Inline Default Values 458
Using Static URL Segments 460
Defining Custom Segment Variables 465
Using Custom Variables as Action Method Parameters 468
Defining Optional URL Segments 469
Defining Variable-Length Routes 471
Constraining Routes 473
Constraining a Route Using a Regular Expression 477
Using Type and Value Constraints 478
Combining Constraints 479
Defining a Custom Constraint 481
Defining an Inline Custom Constraint 482
Using Attribute Routing 483
Preparing for Attribute Routing 483
Applying Attribute Routing 484
Changing the Name of an Action Method 485
Creating a More Complex Route 486
Applying Route Constraints 487
Summary 488
Chapter 16: Advanced Routing Features 489
Preparing the Example Project 490
Generating Outgoing URLs in Views 491
Generating Outgoing Links 491
Targeting Other Controllers 495
Passing Extra Values 497
Generating Fully Qualified URLs 499
Generating a URL from a Specific Route 500
Generating URLs (and Not Links) 503
Generating URLs in Action Methods 503
Customizing the Routing System 504
Changing the Routing System Configuration 504
Creating a Custom Route Class 506
Routing Incoming URLs 507
Applying a Custom Route Class 509
Routing to MVC Controllers 510
Generating Outgoing URLs 514
Working with Areas 517
Creating an Area 517
Creating an Area Route 518
Populating an Area 519
Generating Links to Actions in Areas 522
URL Schema Best Practices 523
Making Your URLs Clean and Human-Friendly 523
GET and POST: Picking the Right One 524
Summary 525
Chapter 17: Controllers and Actions 526
Preparing the Example Project 527
Preparing the Views 528
Understanding Controllers 530
Creating Controllers 531
Creating POCO Controllers 531
Using the MVC Controller API 532
Using the Controller Base Class 533
Receiving Context Data 535
Getting Data from Context Objects 535
Getting Context Data in a POCO Controller 537
Using Action Method Parameters 539
Producing a Response 541
Producing a Response Using the Context Object 541
Understanding Action Results 543
Producing an HTML Response 545
Understanding the Search for a View File 547
Passing Data from an Action Method to a View 549
Using a View Model Object 549
Passing Data with the View Bag 553
Performing Redirections 554
Redirecting to a Literal URL 555
Redirecting to a Routing System URL 557
Redirecting to an Action Method 558
Using the Post/Redirect/Get Pattern 559
Using Temp Data 560
Returning Different Types of Content 562
Producing a JSON Response 562
Using Objects to Generate Responses 563
Responding with the Contents of Files 564
Returning Errors and HTTP Codes 566
Sending a Specific HTTP Result Code 567
Sending a 404 Result Using a Convenience Class 568
Understanding the Other Action Result Classes 568
Summary 569
Chapter 18: Dependency Injection 570
Preparing the Example Project 571
Creating the Model and Repository 572
Creating the Controller and View 573
Creating the Unit Test Project 575
Creating Loosely Coupled Components 575
Examining Closely Coupled Components 576
Decoupling Components for Unit Testing 577
Using a Type Broker 579
Introducing ASP.NET Dependency Injection 583
Preparing for Dependency Injection 583
Configuring the Service Provider 584
Unit Testing a Controller with a Dependency 586
Using Dependency Chains 587
Using Dependency Injection for Concrete Types 589
Understanding Service Life Cycles 592
Using the Transient Life Cycle 593
Using a Factory Function 595
Using the Scoped Life Cycle 597
Using the Singleton Life Cycle 599
Using Action Injection 600
Using the Property Injection Attributes 601
Manually Requesting an Implementation Object 601
Summary 602
Chapter 19: Filters 603
Preparing the Example Project 604
Enabling SSL 605
Creating the Controller and View 605
Using Filters 607
Understanding Filters 610
Getting Context Data 611
Using Authorization Filters 612
Creating an Authorization Filter 612
Using Action Filters 615
Creating an Action Filter 616
Creating an Asynchronous Action Filter 618
Using Result Filters 619
Creating a Result Filter 620
Creating an Asynchronous Result Filter 622
Creating a Hybrid Action/Result Filter 623
Using Exception Filters 625
Creating an Exception Filter 626
Using Dependency Injection for Filters 628
Resolving Filter Dependencies 628
Creating Filters with Dependencies 630
Applying the Filters 631
Managing Filter Life Cycles 633
Applying the Filter 634
Creating Global Filters 636
Understanding and Changing Filter Order 638
Changing Filter Order 640
Summary 641
Chapter 20: API Controllers 642
Preparing the Example Project 643
Creating the Model and Repository 643
Creating the Controller and Views 645
Setting the HTTP Port 648
Understanding the Role of RESTful Controllers 649
Understanding the Speed Problem 649
Understanding the Efficiency Problem 649
Understanding the Openness Problem 650
Introducing REST and API Controllers 650
Creating an API Controller 651
Defining the Route 653
Declaring Dependencies 653
Defining the Action Methods 654
Defining the Action Results 655
Testing an API Controller 656
Testing the GET Operations 656
Testing the POST Operation 658
Testing the PUT Operation 658
Testing the Patch Operation 659
Testing the Delete Operation 660
Using the API Controller in the Browser 660
Understanding Content Formatting 662
Understanding the Default Content Policy 663
Understanding Content Negotiation 664
Enabling XML Formatting 665
Specifying an Action Data Format 667
Getting the Data Format from the Route or Query String 668
Enabling Full Content Negotiation 670
Receiving Different Data Formats 671
Summary 672
Chapter 21: Views 673
Preparing the Example Project 674
Creating a Custom View Engine 675
Creating a Custom IView 677
Creating an IViewEngine Implementation 678
Registering a Custom View Engine 679
Testing the View Engine 680
Working with the Razor Engine 682
Preparing the Example Project 683
Demystifying Razor Views 685
Understanding the Class Name 686
Understanding the Base Class 686
Understanding the View Rendering 688
Adding Dynamic Content to a Razor View 689
Using Layout Sections 689
Testing for Sections 693
Rendering Optional Sections 693
Using Partial Views 695
Creating a Partial View 695
Applying a Partial View 695
Using Strongly Typed Partial Views 697
Adding JSON Content to Views 698
Configuring Razor 700
Understanding View Location Expanders 701
Creating a Simple View Location Expander 702
Applying the View Location Expander 702
Selecting Specific Views for Requests 703
Summary 706
Chapter 22: View Components 707
Preparing the Example Project 708
Creating the Models and Repositories 708
Creating the Controller and Views 710
Configuring the Application 713
Understanding View Components 714
Creating a View Component 714
Creating POCO View Components 715
Deriving from the ViewComponent Base Class 716
Understanding View Component Results 718
Returning a Partial View 719
Returning HTML Fragments 721
Getting Context Data 723
Providing Context from the Parent View Using Arguments 726
Creating Asynchronous View Components 729
Creating Hybrid Controller/View Component Classes 731
Creating the Hybrid Views 732
Applying the Hybrid Class 733
Summary 735
Chapter 23: Understanding Tag Helpers 736
Preparing the Example Project 737
Creating the Model and Repository 737
Creating the Controller, Layout, and Views 738
Configuring the Application 741
Creating a Tag Helper 742
Defining the Tag Helper Class 743
Receiving Context Data 744
Producing Output 745
Registering Tag Helpers 746
Using a Tag Helper 747
Managing the Scope of a Tag Helper 749
Narrowing the Scope of a Tag Helper 750
Widening the Scope of a Tag Helper 751
Advanced Tag Helper Features 754
Creating Shorthand Elements 754
Prepending and Appending Content and Elements 756
Inserting Content Around the Output Element 757
Inserting Content Inside the Output Element 759
Getting View Context Data and Using Dependency Injection 760
Working with the View Model 762
Coordinating Between Tag Helpers 765
Suppressing the Output Element 767
Summary 768
Chapter 24: Using the Form Tag Helpers 769
Preparing the Example Project 770
Resetting the Views and Layout 770
Working with Form Elements 772
Setting the Form Target 773
Using the Anti-forgery Feature 774
Working with Input Elements 776
Configuring Input Elements 777
Formatting Data Values 779
Applying Formatting via the Model Class 781
Working with Label Elements 782
Working with Select and Option Elements 784
Using a Data Source to Populate a select Element 786
Generating Option Elements from an enum 786
Generating Option Elements from the Model 788
Using a Custom Tag Helper to Generate Option Elements from the Model 789
Working with Text Areas 791
Understanding the Validation Form Tag Helpers 793
Summary 793
Chapter 25: Using the Other Built-in Tag Helpers 794
Preparing the Example Project 795
Using the Hosting Environment Tag Helper 796
Using the JavaScript and CSS Tag Helpers 797
Managing JavaScript Files 797
Selecting JavaScript Files 798
Narrowing the Globbing Pattern 801
Excluding Files 802
Using the Hosting Environment to Select Files 803
Working with Content Delivery Networks 805
Managing CSS Stylesheets 807
Selecting Stylesheets 808
Working with Content Delivery Networks 809
Working with Anchor Elements 810
Working with Image Elements 811
Using the Data Cache 812
Setting Cache Expiry 815
Setting a Fixed Expiry Point 816
Setting a Last-Used Expiry Period 817
Using Cache Variations 817
Using Application-Relative URLs 819
Summary 822
Chapter 26: Model Binding 823
Preparing the Example Project 824
Creating the Model and Repository 824
Creating the Controller and View 826
Configuring the Application 827
Understanding Model Binding 829
Understanding Default Binding Values 830
Binding Simple Types 832
Binding Complex Types 833
Creating Easily Bound HTML 835
Specifying Custom Prefixes 838
Selectively Binding Properties 842
Binding to Arrays and Collections 844
Binding to Arrays 844
Binding to Collections 846
Binding to Collections of Complex Types 848
Specifying a Model Binding Source 851
Selecting a Standard Binding Source 852
Using Headers As Binding Sources 853
Binding Complex Types from Headers 855
Using Request Bodies as Binding Sources 857
Summary 859
Chapter 27: Model Validation 860
Preparing the Example Project 861
Creating the Model 862
Creating the Controller 862
Creating the Layout and Views 863
Understanding the Need for Model Validation 866
Explicitly Validating a Model 866
Displaying Validation Errors to the User 869
Displaying Validation Messages 871
Configuring the Default Validation Error Messages 873
Displaying Property-Level Validation Messages 875
Displaying Model-Level Messages 877
Specifying Validation Rules Using Metadata 880
Creating a Custom Property Validation Attribute 883
Performing Client-Side Validation 885
Performing Remote Validation 888
Summary 891
Chapter 28: Getting Started with Identity 892
Preparing the Example Project 893
Creating the Controller and View 894
Setting Up ASP.NET Core Identity 896
Creating the User Class 896
Configuring the View Imports 897
Creating the Database Context Class 898
Configuring the Database Connection String Setting 898
Creating the Identity Database 901
Using ASP.NET Core Identity 901
Enumerating User Accounts 901
Creating Users 904
Testing the Create Functionality 906
Validating Passwords 908
Implementing a Custom Password Validator 910
Validating User Details 915
Implementing Custom User Validation 918
Completing the Administration Features 921
Implementing the Delete Feature 921
Implementing the Edit Feature 923
Creating the View 926
Summary 928
Chapter 29: Applying ASP.NET Core Identity 929
Preparing the Example Project 929
Authenticating Users 930
Preparing to Implement Authentication 932
Adding User Authentication 935
Testing Authentication 937
Authorizing Users with Roles 938
Creating and Deleting Roles 939
Creating the Views 941
Testing, Creating, and Deleting Roles 944
Managing Role Memberships 944
Testing and Editing Role Membership 948
Using Roles for Authorization 950
Seeding the Database 953
Summary 957
Chapter 30: Advanced ASP.NET Core Identity 958
Preparing the Example Project 958
Adding Custom User Properties 960
Preparing for Database Migration 963
Testing the Custom Properties 964
Working with Claims and Policies 964
Understanding Claims 965
Creating Claims 969
Using Policies 973
Creating Custom Policy Requirements 976
Using Policies to Authorize Access to Resources 979
Creating the Resource Authorization Policy and Handler 981
Using Third-Party Authentication 985
Registering the Application with Google 985
Enabling Google Authentication 985
Summary 990
Chapter 31: Model Conventions and Action Constraints 991
Preparing the Example Project 991
Creating the View Model, Controller, and View 992
Using the Application Model and Model Conventions 994
Understanding the Application Model 995
Customizing the Application Model 997
Understanding the Role of Model Conventions 999
Creating a Model Convention 1000
Using Conventions That Add or Remove Models 1001
Understanding Model Convention Execution Order 1005
Creating Global Model Conventions 1006
Using Action Constraints 1008
Preparing the Example Project 1008
Understanding Action Constraints 1011
Creating an Action Constraint 1012
Creating a Comparative Action Constraint 1014
Resolving Dependencies in Action Constraints 1016
Summary 1019
Index 1020

Erscheint lt. Verlag 24.10.2017
Zusatzinfo XXIX, 1017 p. 292 illus., 281 illus. in color.
Verlagsort Berkeley
Sprache englisch
Themenwelt Mathematik / Informatik Informatik Software Entwicklung
Schlagworte C# • Microsoft • .NET • .NET development • .NET Framework • .NET Platform • .NET Standard • Single Page Application • Spa • Test-Driven Development • Visual Studio • Web Development
ISBN-10 1-4842-3150-3 / 1484231503
ISBN-13 978-1-4842-3150-0 / 9781484231500
Haben Sie eine Frage zum Produkt?
PDFPDF (Wasserzeichen)
Größe: 22,7 MB

DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasser­zeichen und ist damit für Sie persona­lisiert. Bei einer missbräuch­lichen Weiter­gabe des eBooks an Dritte ist eine Rück­ver­folgung an die Quelle möglich.

Dateiformat: PDF (Portable Document Format)
Mit einem festen Seiten­layout eignet sich die PDF besonders für Fach­bücher mit Spalten, Tabellen und Abbild­ungen. Eine PDF kann auf fast allen Geräten ange­zeigt werden, ist aber für kleine Displays (Smart­phone, eReader) nur einge­schränkt geeignet.

Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.

Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.

Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.

EPUBEPUB (Adobe DRM)

Kopierschutz: Adobe-DRM
Adobe-DRM ist ein Kopierschutz, der das eBook vor Mißbrauch schützen soll. Dabei wird das eBook bereits beim Download auf Ihre persönliche Adobe-ID autorisiert. Lesen können Sie das eBook dann nur auf den Geräten, welche ebenfalls auf Ihre Adobe-ID registriert sind.
Details zum Adobe-DRM

Dateiformat: EPUB (Electronic Publication)
EPUB ist ein offener Standard für eBooks und eignet sich besonders zur Darstellung von Belle­tristik und Sach­büchern. Der Fließ­text wird dynamisch an die Display- und Schrift­größe ange­passt. Auch für mobile Lese­geräte ist EPUB daher gut geeignet.

Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen eine Adobe-ID und die Software Adobe Digital Editions (kostenlos). Von der Benutzung der OverDrive Media Console raten wir Ihnen ab. Erfahrungsgemäß treten hier gehäuft Probleme mit dem Adobe DRM auf.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen eine Adobe-ID sowie eine kostenlose App.
Geräteliste und zusätzliche Hinweise

Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.

Mehr entdecken
aus dem Bereich
Das umfassende Handbuch

von Jürgen Sieben

eBook Download (2023)
Rheinwerk Computing (Verlag)
89,90
Eine kompakte Einführung

von Brendan Burns; Joe Beda; Kelsey Hightower; Lachlan Evenson

eBook Download (2023)
dpunkt (Verlag)
39,90