Pro ASP.NET Core MVC -  Adam Freeman

Pro ASP.NET Core MVC (eBook)

(Autor)

eBook Download: PDF
2016 | 6th ed.
XXIX, 1018 Seiten
Apress (Verlag)
978-1-4842-0397-2 (ISBN)
Systemvoraussetzungen
46,00 inkl. MwSt
  • Download sofort lieferbar
  • Zahlungsarten anzeigen

Now in its 6th edition, the best selling book on MVC is now updated for ASP.NET Core MVC. It contains detailed explanations of the new 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.

This book follows the same format and style as the popular previous editions but brings everything up to date for the new ASP.NET Core MVC release. It presents a fully worked case study of a functioning ASP.NET MVC application that readers can use as a template for their own projects.


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 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 new ASP.NET Core MVC 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.
Visual Studio 2017 updates for this book are now available. Follow the Download Source Code link for this book on the Apress website.Now in its 6th edition, the best selling book on MVC is now updated for ASP.NET Core MVC. It contains detailed explanations of the new 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 asWeb 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.This book follows the same format and style as the popular previous editions but brings everything up to date for the new ASP.NET Core MVC release. It presents a fully worked case study of a functioning ASP.NET MVC application that readers can use as a template for their own projects.What You Will Learn:Gain a solid architectural understanding of ASP.NET Core MVCExplore the entire ASP.NET MVC Framework as a cohesive wholeSeehow MVC and test-driven development work in actionLearn what's new in ASP.NET Core MVC 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 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 new ASP.NET Core MVC 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 29
Chapter 1: ASP.NET Core MVC in Context 30
Understanding the History of ASP.NET Core MVC 30
ASP.NET Web Forms 30
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
Key Benefits of ASP.NET Core MVC 33
MVC Architecture 33
Extensibility 33
Tight Control over HTML and HTTP 33
Testability 34
Powerful Routing System 34
Modern API 35
Cross-Platform 35
ASP.NET Core MVC Is Open Source 35
What Do I Need to Know? 35
What Is the Structure of This Book? 35
Part 1: Introducing ASP.NET Core MVC 35
Part 2: ASP.NET Core MVC in Detail 36
What’s New in This Edition? 36
Where Can I Get the Example Code? 36
Summary 36
Chapter 2: Your First MVC Application 37
Installing Visual Studio 37
Creating a New ASP.NET Core MVC Project 39
Adding the Controller 43
Understanding Routes 45
Rendering Web Pages 46
Creating and Rendering a View 46
Adding Dynamic Output 49
Creating a Simple Data-Entry Application 51
Setting the Scene 51
Designing a Data Model 52
Creating a Second Action and a Strongly Typed View 53
Linking Action Methods 54
Building the Form 56
Receiving Form Data 57
Using Model Binding 59
Storing Responses 60
Displaying the Responses 62
Adding Validation 64
Highlighting Invalid Fields 68
Styling the Content 71
Styling the Welcome View 71
Styling the RsvpForm View 73
Styling the Thanks View 75
Styling the List View 76
Summary 77
Chapter 3: The MVC Pattern, Projects, and Conventions 78
The History of MVC 78
Understanding the MVC Pattern 78
Understanding Models 79
Understanding Controllers 79
Understanding Views 80
The ASP.NET Implementation of MVC 80
Comparing MVC to Other Patterns 80
Understanding the Smart UI Pattern 81
Understanding the Model-View Architecture 82
Understanding Classic Three-Tier Architectures 82
Understanding Variations on MVC 83
Understanding the Model-View-Presenter Pattern 83
Understanding the Model-View-View Model Pattern 83
Understanding ASP.NET Core MVC Projects 84
Creating the Project 84
Understanding MVC Conventions 87
Following Conventions for Controller Classes 87
Following Conventions for Views 88
Following Conventions for Layouts 88
Summary 89
Chapter 4: Essential C# Features 90
Preparing the Example Project 90
Enabling ASP.NET Core MVC 92
Creating the MVC Application Components 93
Creating the Model 93
Creating the Controller and View 94
Using the Null Conditional Operator 95
Chaining the Null Conditional Operator 96
Combining the Conditional and Coalescing Operators 97
Using Automatically Implemented Properties 98
Using Auto-Implemented Property Initializers 99
Creating Read-Only Automatically Implemented Properties 100
Using String Interpolation 101
Using Object and Collection Initializers 102
Using an Index Initializer 104
Using Extension Methods 105
Applying Extension Methods to an Interface 107
Creating Filtering Extension Methods 108
Using Lambda Expressions 110
Defining Functions 111
Using Lambda Expression Methods and Properties 114
Using Type Inference and Anonymous Types 116
Using Anonymous Types 117
Using Asynchronous Methods 119
Working with Tasks Directly 119
Applying the async and await Keywords 121
Getting Names 122
Summary 124
Chapter 5: Working with Razor 125
Preparing the Example Project 126
Defining the Model 127
Creating the Controller 127
Creating the View 128
Working with the Model Object 129
Using View Imports 131
Working with Layouts 133
Creating the Layout 133
Applying a Layout 135
Using a View Start File 136
Using Razor Expressions 138
Inserting Data Values 139
Setting Attribute Values 141
Using Conditional Statements 142
Enumerating Arrays and Collections 144
Summary 146
Chapter 6: Working with Visual Studio 147
Preparing the Example Project 147
Creating the Model 148
Creating the Controller and View 150
Managing Software Packages 152
Understanding NuGet 152
Understanding the NuGet Packages List and Location 153
Understanding Bower 154
Understanding the Bower Packages List 154
Understanding Iterative Development 158
Making Changes to Razor Views 158
Making Changes to C# Classes 160
Compiling Classes Automatically 160
Enabling Developer Exception Pages 162
Using the Debugger 163
Setting a Breakpoint 164
Viewing Data Values in the Code Editor 165
Using the Locals Window 167
Using Browser Link 168
Setting Up Browser Link 168
Using Browser Link 169
Using Multiple Browsers 171
Preparing JavaScript and CSS for Deployment 174
Enabling Static Content Delivery 174
Adding Static Content to the Project 175
Updating the View 177
Bundling and Minifying in MVC Applications 178
Installing the Visual Studio Extension 178
Bundling and Minifying Files 179
Summary 182
Chapter 7: Unit Testing MVC Applications 183
Preparing the Example Project 184
Enabling the Built-in Tag Helpers 184
Adding Actions to the Controller 184
Creating the Data Entry Form 185
Updating the Index View 186
Unit Testing MVC Applications 187
Creating a Unit test Project 188
Configuring the Unit Test Project 189
Adding the Application Project Reference 190
Writing and Running Unit Tests 191
Running Tests with the Test Explorer 193
Isolating Components for Unit Testing 195
Isolating a Component 197
Improving Unit Tests 203
Parameterizing a Unit Test 203
Getting Test Data from a Method or Property 205
Improving Fake Implementations 207
Adding a Mocking Framework 209
Creating a Mock Object 211
Summary 213
Chapter 8: SportsStore: A Real Application 214
Getting Started 215
Creating the MVC Project 215
Adding the NuGet Packages 216
Creating the Folder Structure 218
Configuring the Application 218
Creating the Unit Test Project 220
Checking and Running the Application 222
Starting the Domain Model 223
Creating a Repository 223
Creating a Fake Repository 224
Registering the Repository Service 224
Displaying a List of Products 225
Adding a Controller 227
Adding and Configuring the View 228
Setting the Default Route 230
Running the Application 231
Preparing a Database 231
Installing Entity Framework Core 232
Creating the Database Classes 233
Creating the Repository Class 235
Defining the Connection String 235
Configuring the Application 236
Creating and Applying the Database Migration 238
Adding Pagination 239
Displaying Page Links 241
Adding the View Model 242
Adding the Tag Helper Class 242
Adding the View Model Data 245
Displaying the Page Links 248
Improving the URLs 250
Styling the Content 251
Installing the Bootstrap Package 252
Applying Bootstrap Styles to the Layout 252
Creating a Partial View 255
Summary 257
Chapter 9: SportsStore: Navigation 258
Adding Navigation Controls 258
Filtering the Product List 258
Refining the URL Scheme 262
Building a Category Navigation Menu 266
Creating the Navigation View Component 266
Generating Category Lists 268
Creating the View 269
Highlighting the Current Category 271
Correcting the Page Count 274
Building the Shopping Cart 276
Defining the Cart Model 277
Adding the Add to Cart Buttons 281
Enabling Sessions 283
Implementing the Cart Controller 284
Defining Session State Extension Methods 286
Displaying the Contents of the Cart 287
Summary 290
Chapter 10: SportsStore: Completing the Cart 291
Refining the Cart Model with a Service 291
Creating a Storage-Aware Cart Class 291
Registering the Service 292
Simplifying the Cart Controller 293
Completing the Cart Functionality 294
Removing Items from the Cart 294
Adding the Cart Summary Widget 296
Adding the Font Awesome Package 296
Creating the View Component Class and View 297
Submitting Orders 299
Creating the Model Class 299
Adding the Checkout Process 300
Implementing Order Processing 304
Extending the Database 304
Creating the Order Repository 305
Completing the Order Controller 307
Displaying Validation Errors 310
Displaying a Summary Page 312
Summary 312
Chapter 11: SportsStore: Administration 313
Managing Orders 313
Enhancing the Model 313
Adding the Actions and View 314
Adding Catalog Management 317
Creating a CRUD Controller 318
Implementing the List View 320
Editing Products 321
Creating the Edit Action Method 322
Creating the Edit View 323
Updating the Product Repository 325
Handling Edit POST Requests 326
Displaying a Confirmation Message 329
Adding Model Validation 330
Enabling Client-Side Validation 333
Creating New Products 335
Deleting Products 337
Summary 340
Chapter 12: SportsStore: Security and Deployment 341
Securing the Administration Features 341
Adding the Identity Package to the Project 341
Creating the Identity Database 342
Creating the Context Class 342
Defining the Connection String 343
Configuring the Application 343
Defining the Seed Data 345
Creating and Applying the Database Migration 345
Applying a Basic Authorization Policy 346
Creating the Account Controller and Views 348
Testing the Security Policy 352
Deploying the Application 352
Creating the Databases 353
Opening Firewall Access for Configuration 353
Getting the Connection Strings 354
Preparing the Application 354
Creating the Error Controller and View 354
Defining the Production Database Settings 355
Configuring the Application 356
Updating the Project Configuration 358
Applying the Database Migrations 359
Deploying the Application 359
Summary 364
Chapter 13: Working with Visual Studio Code 365
Setting Up the Development Environment 365
Installing Node.js 365
Installing Node.js on Windows 366
Installing Node.js on OS X/macOS 366
Installing Node.js on Linux 367
Checking the Node Installation 367
Installing Git 367
Installing Git on Windows or OS X/macOS 367
Installing Git on Linux 367
Checking the Git Installation 367
Installing Yeoman, Bower, and Gulp 368
Installing .NET Core 368
Installing .NET Core on Windows 368
Installing .NET Core on OS X/macOS 369
Installing .NET Core on Linux 369
Checking the .NET Core Installation 369
Installing Visual Studio Code 370
Installing Visual Studio Code on Windows 370
Installing Visual Studio Code on OS X/macOS 370
Installing Visual Studio Code on Linux 370
Checking the Visual Studio Code Installation 370
Installing the Visual Studio Code C# Extension 371
Creating an ASP.NET Core Project 372
Preparing the Project with Visual Studio Code 373
Adding NuGet Packages to the Project 374
Adding Client-Side Packages to the Project 375
Configuring the Application 377
Building and Running the Project 377
Re-creating the PartyInvites Application 378
Creating the Model and Repository 378
Creating the Database 381
Adding the Database Packages 382
Creating and Applying the Database Migration 383
Creating the Controllers and Views 383
Unit Testing in Visual Studio Code 388
Configuring the Application 388
Creating a Unit Test 389
Running Tests 390
Summary 391
Part II: ASP.NET Core MVC in Detail 392
Chapter 14: Configuring Applications 393
Preparing the Example Project 394
Understanding the JSON Configuration Files 396
Configuring the Solution 397
Configuring the Project 399
Adding Dependencies to the project.json File 400
Registering Development Tools in the project.json File 401
Understanding the Program Class 402
Understanding the Startup Class 403
Understanding How the Startup Class Is Used 405
Understanding ASP.NET Services 406
Understanding the MVC Services 408
Understanding ASP.NET Middleware 409
Creating Content-Generating Middleware 409
Using Services in Middleware 411
Creating Short-Circuiting Middleware 412
Creating Request-Editing Middleware 414
Creating Response-Editing Middleware 416
Understanding How the Configure Method Is Invoked 418
Using the Application Builder 419
Using the Hosting Environment 420
Using the Logging Factory 422
Creating Custom Log Entries 425
Adding the Remaining Middleware Components 427
Enabling Exception Handling 427
Enabling Browser Link 429
Enabling Static Content 430
Using Configuration Data 432
Reading Configuration Data 432
Using Configuration Data 435
Using Configuration Data for Built-in Middleware Components 437
Configuring MVC Services 438
Dealing with Complex Configurations 440
Creating Different External Configuration Files 440
Creating Different Configuration Methods 441
Creating Different Configuration Classes 442
Summary 444
Chapter 15: URL Routing 445
Preparing the Example Project 447
Creating the Model Class 448
Creating the Example Controllers 449
Creating the View 450
Introducing URL Patterns 451
Creating and Registering a Simple Route 453
Defining Default Values 454
Defining Inline Default Values 455
Using Static URL Segments 457
Defining Custom Segment Variables 462
Using Custom Variables as Action Method Parameters 464
Defining Optional URL Segments 466
Defining Variable-Length Routes 468
Constraining Routes 471
Constraining a Route Using a Regular Expression 474
Using Type and Value Constraints 475
Combining Constraints 476
Defining a Custom Constraint 477
Defining an Inline Custom Constraint 479
Using Attribute Routing 480
Preparing for Attribute Routing 480
Applying Attribute Routing 481
Changing the Name of an Action Method 482
Creating a More Complex Route 483
Applying Route Constraints 484
Summary 484
Chapter 16: Advanced Routing Features 485
Preparing the Example Project 486
Generating Outgoing URLs in Views 488
Generating Outgoing Links 488
Targeting Other Controllers 492
Passing Extra Values 493
Generating Fully Qualified URLs 496
Generating a URL from a Specific Route 497
Generating URLs (and Not Links) 499
Generating URLs in Action Methods 499
Customizing the Routing System 500
Changing the Routing System Configuration 501
Creating a Custom Route Class 502
Routing Incoming URLs 503
Applying a Custom Route Class 505
Routing to MVC Controllers 507
Generating Outgoing URLs 510
Working with Areas 513
Creating an Area 513
Creating an Area Route 514
Populating an Area 515
Generating Links to Actions in Areas 517
URL Schema Best Practices 519
Make Your URLs Clean and Human-Friendly 519
GET and POST: Pick the Right One 520
Summary 521
Chapter 17: Controllers and Actions 522
Preparing the Example Project 523
Preparing the Views 525
Understanding Controllers 527
Creating Controllers 527
Creating POCO Controllers 527
Using the MVC Controller API 529
Using the Controller Base Class 530
Receiving Context Data 531
Getting Data from Context Objects 531
Getting Context Data in a POCO Controller 533
Using Action Method Parameters 536
Producing a Response 538
Producing a Response Using the Context Object 538
Understanding Action Results 539
Producing an HTML Response 541
Understanding the Search for a View File 542
Passing Data from an Action Method to a View 545
Using a View Model Object 545
Passing Data with the View Bag 548
Performing Redirections 550
Redirecting to a Literal URL 550
Redirecting to a Routing System URL 552
Redirecting to an Action Method 553
Using the Post/Redirect/Get Pattern 555
Using Temp Data 556
Returning Different Types of Content 557
Producing a JSON Response 557
Using Objects to Generate Responses 558
Responding with the Contents of Files 559
Returning Errors and HTTP Codes 561
Sending a Specific HTTP Result Code 562
Sending a 404 Result Using a Convenience Class 563
Understanding the Other Action Result Classes 563
Summary 564
Chapter 18: Dependency Injection 565
Preparing the Example Project 566
Creating the Model and Repository 567
Creating the Controller and View 569
Creating the Unit Test Project 571
Creating Loosely Coupled Components 572
Examining Closely Coupled Components 572
De-coupling Components for Unit Testing 573
Using a Type Broker 575
Introducing ASP.NET Dependency Injection 579
Preparing for Dependency Injection 579
Configuring the Service Provider 580
Unit Testing a Controller with a Dependency 582
Using Dependency Chains 583
Using Dependency Injection for Concrete Types 586
Understanding Service Life Cycles 588
Using the Transient Life Cycle 588
Using a Factory Function 591
Using the Scoped Life Cycle 592
Using the Singleton Life Cycle 594
Using Action Injection 595
Using the Property Injection Attributes 595
Manually Requesting an Implementation Object 596
Summary 597
Chapter 19: Filters 598
Preparing the Example Project 599
Enabling SSL 600
Creating the Controller and View 601
Using Filters 603
Understanding Filters 606
Getting Context Data 606
Using Authorization Filters 607
Creating an Authorization Filter 608
Using Action Filters 610
Creating an Action Filter 612
Creating an Asynchronous Action Filter 614
Using Result Filters 615
Creating a Result Filter 616
Creating an Asynchronous Result Filter 617
Creating a Hybrid Action/Result Filter 619
Using Exception Filters 621
Creating an Exception Filter 622
Using Dependency Injection for Filters 624
Resolving Filter Dependencies 624
Creating Filters with Dependencies 625
Applying the Filters 627
Managing Filter Life Cycles 628
Applying the Filter 630
Creating Global Filters 631
Understanding and Changing Filter Order 634
Changing Filter Order 636
Summary 637
Chapter 20: API Controllers 638
Preparing the Example Project 639
Creating the Model and Repository 639
Creating the Controller and Views 641
Configuring the Application 643
Setting the HTTP Port 644
Understanding the Role of RESTful Controllers 645
Understanding the Speed Problem 646
Understanding the Efficiency Problem 646
Understanding the Openness Problem 647
Introducing REST and API Controllers 647
Creating an API Controller 648
Defining the Route 650
Declaring Dependencies 650
Defining the Action Methods 650
Defining the Action Results 651
Testing an API Controller 652
Testing the GET Operations 653
Testing the POST Operation 654
Testing the PUT Operation 655
Testing the Delete Operation 655
Using the API Controller in the Browser 656
Understanding Content Formatting 658
Understanding the Default Content Policy 659
Understanding Content Negotiation 660
Enabling XML Formatting 661
Specifying an Action Data Format 663
Getting the Data Format from the Route or Query String 664
Enabling Full Content Negotiation 665
Receiving Different Data Formats 667
Summary 668
Chapter 21: Views 669
Preparing the Example Project 670
Creating a Custom View Engine 672
Creating a Custom IView 673
Creating an IViewEngine Implementation 674
Registering a Custom View Engine 675
Testing the View Engine 676
Working with the Razor Engine 679
Preparing the Example Project 679
Demystifying Razor Views 681
Understanding the Class Name 682
Understanding the Base Class 683
Understanding the View Rendering 684
Adding Dynamic Content to a Razor View 685
Using Layout Sections 685
Testing for Sections 688
Rendering Optional Sections 689
Using Partial Views 691
Creating a Partial View 691
Applying a Partial View 691
Using Strongly Typed Partial Views 692
Adding JSON Content to Views 694
Configuring Razor 696
Understanding View Location Expanders 697
Creating a Simple View Location Expander 697
Applying the View Location Expander 698
Selecting Specific Views for Requests 699
Summary 702
Chapter 22: View Components 703
Preparing the Example Project 704
Creating the Models and Repositories 705
Creating the Controller and Views 707
Configuring the Application 710
Understanding View Components 711
Creating a View Component 712
Creating POCO View Components 712
Deriving from the ViewComponent Base Class 714
Understanding View Component Results 715
Returning a Partial View 716
Returning HTML Fragments 719
Getting Context Data 721
Providing Context from the Parent View Using Arguments 723
Creating Asynchronous View Components 727
Creating Hybrid Controller/View Component Classes 730
Creating the Hybrid Views 731
Applying the Hybrid Class 732
Summary 734
Chapter 23: Understanding Tag Helpers 735
Preparing the Example Project 736
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 742
Receiving Context Data 743
Producing Output 744
Registering Tag Helpers 745
Using a Tag Helper 746
Managing the Scope of a Tag Helper 748
Narrowing the Scope of a Tag Helper 749
Widening the Scope of a Tag Helper 750
Advanced Tag Helper Features 752
Creating Shorthand Elements 752
Prepending and Appending Content and Elements 755
Inserting Content Around the Output Element 755
Inserting Content Inside the Output Element 757
Getting View Context Data and Using Dependency Injection 759
Working with the View Model 761
Coordinating Between Tag Helpers 763
Suppressing the Output Element 765
Summary 767
Chapter 24: Using the Form Tag Helpers 768
Preparing the Example Project 769
Changing the Tag Helper Registration 769
Resetting the Views and Layout 770
Working with Form Elements 772
Setting the Form Target 772
Using the Anti-forgery Feature 773
Working with Input Elements 775
Configuring Input Elements 776
Formatting Data Values 778
Applying Formatting via the Model Class 780
Working with Label Elements 781
Working with Select and Option Elements 783
Using a Data Source to Populate a select Element 785
Generating Option Elements from an enum 785
Generating Option Elements from the Model 786
Using a Custom Tag Helper to Generate Option Elements from the Model 788
Working with Text Areas 790
Understanding the Validation Form Tag Helpers 792
Summary 792
Chapter 25: Using the Other Built-in Tag Helpers 793
Preparing the Example Project 794
Using the Hosting Environment Tag Helper 795
Using the JavaScript and CSS Tag Helpers 796
Managing JavaScript Files 796
Selecting JavaScript Files 797
Narrowing the Globbing Pattern 800
Excluding Files 800
Using the Hosting Environment to Select Files 801
Working with Content Delivery Networks 803
Managing CSS Stylesheets 805
Selecting Stylesheets 805
Working with Content Delivery Networks 807
Working with Anchor Elements 808
Working with Image Elements 809
Using the Data Cache 810
Setting Cache Expiry 813
Setting a Fixed Expiry Point 813
Setting a Last-Used Expiry Period 814
Using Cache Variations 814
Using Application-Relative URLs 815
Summary 818
Chapter 26: Model Binding 819
Preparing the Example Project 820
Creating the Model and Repository 821
Creating the Controller and View 822
Configuring the Application 824
Understanding Model Binding 825
Understanding Default Binding Values 827
Binding Simple Types 829
Binding Complex Types 830
Creating Easily Bound HTML 832
Specifying Custom Prefixes 835
Selectively Binding Properties 839
Binding to Arrays and Collections 841
Binding to Arrays 841
Binding to Collections 843
Binding to Collections of Complex Types 844
Specifying a Model Binding Source 848
Selecting a Standard Binding Source 849
Using Headers As Binding Sources 850
Binding Complex Types from Headers 852
Using Request Bodies as Binding Sources 853
Summary 856
Chapter 27: Model Validation 857
Preparing the Example Project 858
Creating the Model 860
Creating the Controller 860
Creating the Layout and Views 861
Understanding the Need for Model Validation 863
Explicitly Validating a Model 864
Displaying Validation Errors to the User 866
Displaying Validation Messages 869
Configuring the Default Validation Error Messages 871
Displaying Property-Level Validation Messages 873
Displaying Model-Level Messages 875
Specifying Validation Rules Using Metadata 878
Creating a Custom Property Validation Attribute 882
Performing Client-Side Validation 884
Performing Remote Validation 886
Summary 890
Chapter 28: Getting Started with Identity 891
Preparing the Example Project 892
Creating the Controller and View 894
Setting Up ASP.NET Core Identity 896
Adding the Identity Package to the Application 896
Creating the User Class 897
Configuring the View Imports 898
Creating the Database Context Class 899
Configuring the Database Connection String Setting 899
Configuring the Identity Services and Middleware 901
Creating the Identity Database 902
Using ASP.NET Core Identity 903
Enumerating User Accounts 903
Creating Users 906
Testing the Create Functionality 909
Validating Passwords 910
Implementing a Custom Password Validator 913
Validating User Details 918
Implementing Custom User Validation 921
Completing the Administration Features 924
Implementing the Delete Feature 925
Implementing the Edit Feature 926
Creating the View 929
Summary 931
Chapter 29: Applying ASP.NET Core Identity 932
Preparing the Example Project 932
Authenticating Users 933
Preparing to Implement Authentication 936
Adding User Authentication 939
Testing Authentication 941
Authorizing Users with Roles 942
Creating and Deleting Roles 943
Creating the Views 945
Testing, Creating, and Deleting Roles 948
Managing Role Memberships 948
Testing and Editing Role Membership 952
Using Roles for Authorization 954
Seeding the Database 958
Summary 961
Chapter 30: Advanced ASP.NET Core Identity 962
Preparing the Example Project 962
Adding Custom User Properties 964
Preparing for Database Migration 967
Testing the Custom Properties 968
Working with Claims and Policies 969
Understanding Claims 969
Creating Claims 974
Using Policies 977
Creating Custom Policy Requirements 980
Using Policies to Authorize Access to Resources 983
Creating the Resource Authorization Policy and Handler 986
Using Third-Party Authentication 989
Registering the Application with Google 989
Enabling Google Authentication 990
Summary 995
Chapter 31: Model Conventions and Action Constraints 996
Preparing the Example Project 996
Creating the View Model, Controller, and View 998
Using the Application Model and Model Conventions 1000
Understanding the Application Model 1001
Customizing the Application Model 1003
Understanding the Role of Model Conventions 1005
Creating a Model Convention 1006
Using Conventions That Add or Remove Models 1007
Understanding Model Convention Execution Order 1011
Creating Global Model Conventions 1012
Using Action Constraints 1014
Preparing the Example Project 1014
Understanding Action Constraints 1016
Creating an Action Constraint 1017
Creating a Comparative Action Constraint 1019
Resolving Dependencies in Action Constraints 1022
Summary 1025
Index 1026

Erscheint lt. Verlag 15.9.2016
Zusatzinfo XXIX, 1018 p. 289 illus., 279 illus. in color.
Verlagsort Berkeley
Sprache englisch
Themenwelt Mathematik / Informatik Informatik Programmiersprachen / -werkzeuge
Mathematik / Informatik Informatik Software Entwicklung
Mathematik / Informatik Informatik Web / Internet
Schlagworte ASP.NET Core MVC • Microsoft • MVC • .NET • .NET development
ISBN-10 1-4842-0397-6 / 1484203976
ISBN-13 978-1-4842-0397-2 / 9781484203972
Haben Sie eine Frage zum Produkt?
PDFPDF (Wasserzeichen)
Größe: 32,5 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.

Mehr entdecken
aus dem Bereich
Entwicklung von GUIs für verschiedene Betriebssysteme

von Achim Lingott

eBook Download (2023)
Carl Hanser Verlag GmbH & Co. KG
39,99
Das umfassende Handbuch

von Johannes Ernesti; Peter Kaiser

eBook Download (2023)
Rheinwerk Computing (Verlag)
44,90
Mit über 150 Workouts in Java und Python

von Luigi Lo Iacono; Stephan Wiefling; Michael Schneider

eBook Download (2023)
Carl Hanser Verlag GmbH & Co. KG
29,99